Cell Value does not commit in sfdatagrid no matter what I do

Hi,

I'm using sfDatagrid for Flutter and I have run into a problem, My datagrid has editable columns which means upon a cell receiving focus it is converted to a specific non-text widget such as Textfield, Autocomplete etc, everything works smoothly but there is this issue of cell value not commiting after editable widget returns to it's Text widget form. On Linux ONLY NUMPAD Enter key commits cell value but on Windows neither the normal or numpad enter keys work. Furthermore I require that whenever tab key is pressed cell values commit and the focus is moved to the next cell and it activates it in edit mode. I'll be grateful for an urgent response. Thanks


Best Regards,


Ammar


EDIT: I did not override the enter key in my custom selection manager in case that could have caused this nor is enter key being overridden anywhere else


1 Reply

AP Abinesh Palanisamy Syncfusion Team August 8, 2024 06:56 AM UTC

Hi Ammar


Query

Response

On Linux ONLY NUMPAD Enter key commits cell value but on Windows neither the normal or numpad enter keys work.

Based on the information provided, we conducted tests using a simple sample to replicate the reported issues. However, we were unable to reproduce the issues as described. In the simple sample, the cell value is committed when pressing either the normal or numpad Enter key in Windows.

 

We have tested this scenario using the attached sample. If you are still encountering the same problem, we kindly request that you modify the attached sample to reproduce the issue and provide additional clear details, along with detailed device information. This will greatly assist us in investigating the issue further and providing an appropriate solution as quickly as possible

Furthermore I require that whenever tab key is pressed cell values commit and the focus is moved to the next cell and it activates it in edit mode.

In SfDataGrid, pressing the Tab key moves the focus to the next cell. Additionally, you can customize this behavior using the handleKeyEvent method in the RowSelectionManager. When the Tab key is pressed, the current cell enters edit mode using DataGridController.beginEdit.  Additionally, set autofocus to true in the TextField widget within the buildEditWidget method to ensure that focus moves to the TextField and editing begins. With this approach, pressing the Tab key commits the current cell's value, moves the focus to the next cell, and activates it in edit mode.

 

Code snippet:
 

class CustomSelectionManager extends RowSelectionManager {

  CustomSelectionManager(this.controller);

  DataGridController controller;

  @override

  Future<void> handleKeyEvent(KeyEvent keyEvent) async {

    if (keyEvent.logicalKey == LogicalKeyboardKey.tab) {

      // Handled the Tab key behavior.

      WidgetsBinding.instance.addPostFrameCallback((_) {

        controller.beginEdit(controller.currentCell);

      });

    }

    super.handleKeyEvent(keyEvent);

  }

}



 

We have included a sample and video reference for your reference. Please review this sample for more details and adapt it to suit your specific requirements.

 


Regards,

Abinesh P


Attachment: SfDataGrid_8a0ac512.zip

Loader.
Up arrow icon