Articles in this section
Category / Section

How to cancel editing a cell in Flutter DataTable (SfDataGrid)?

1 min read

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.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied