How To Cancel Editing A Cell In Flutter Datatable (Sfdatagrid)?

Sample date Updated on Sep 13, 2025
cancel-cell-editing celldata-editing datatable disable-editing flutter-datagrid

In this article, we will show how to cancel editing a cell in Flutter DataTable.

Initialize the SfDataGrid widget with the necessary properties. The DataGridSource.onCellBeginEdit method is called when a cell enters edit mode. This method provides the row, rowColumnIndex, and column as parameters. You can use these parameter values to determine whether editing should proceed. Return false if you want to prevent specific cells from entering edit mode

@override
  bool onCellBeginEdit(
    DataGridRow dataGridRow,
    RowColumnIndex rowColumnIndex,
    GridColumn column,
  ) {
    if (column.columnName == 'ID') {
      if (rowColumnIndex.columnIndex == 0 && rowColumnIndex.rowIndex == 2) {
        return false;
      }
    }
    return true;
  }

You can download this example on GitHub.

Up arrow