How to focus custom widgets inside cells?

Hi,

I have a datagrid that has widgets such as textfields and RawAutocomplete provided by flutter. I cannot focus them with arrow key navigation but tab key works fine. How can I set focus to them with arrow key movement? any help will be appreciated.


EDIT: I just realized tab key navigation is broken too, all of this works only when focusing CELLS but not for CELL CHILDREN

EDIT 2: It would be really helpful if any representative would acknowledge this


2 Replies

AM Ammar July 22, 2024 10:30 AM UTC

I would really appreciate an answer for this as this is the sole reason my project is being delayed



AP Abinesh Palanisamy Syncfusion Team July 22, 2024 12:11 PM UTC

Hi Ammar


In SfDataGrid, we do not have direct support for focusing on the widget loaded in the cells by key navigation. When we perform selection or key navigation, the focus is moved to the dataGrid. By default, widgets like TextField get focus when we tap the required widget. Based on the details provided, you need to trigger the focus for the TextField using the arrow keys.


We have a workaround to achieve the expected behavior by using the onCurrentCellActivated callback. This callback is raised after the current cell is applied in the grid cell on the selected row. In the build row, while adding the TextField, the EmployeeDataSource class manages TextEditingController and FocusNode instances for each row. This ensures each text field within the grid has its controller and focus node. The focus is programmatically requested for the corresponding FocusNode in the onCurrentCellActivated callback. Once the value is committed in the respective text field by pressing the Enter key, the focus returns to the SfDataGrid, allowing for continued navigation.


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


Regards,

Abinesh P


Attachment: SfDataGrid_22d3c499.zip

Loader.
Up arrow icon