Select the row via default checkbox instead of the whole row



Currently facing an issue that I want to click the checkbox only for selecting the whole row instead of tap the content of the row. This is because I wish to navigate to the other pages when tapping on the content.
Therefore I hope that, there is a way to do this.
Thank you.


4 Replies 1 reply marked as answer

TP Tamilarasan Paranthaman Syncfusion Team October 16, 2023 02:17 PM UTC

Hi Jacqueline,


Based on the current structure of the DataGrid, selecting rows only through the built-in checkbox column is not supported. However, you can achieve your requirements through a workaround. To implement this, you should use checkboxes at the sample level to select rows programmatically. Additionally, you can restrict row selection when tapping on row contents to meet your needs.


To implement this, use the Checkbox component in a separate column at the sample level instead of the DataGrid's built-in checkbox. In the ` DataGridSource.buildRow` method, return the checkbox if it's a checkbox column. In the `Checkbox.onChanged` callback, set the corresponding row to `DataGridController.selectedRow` to select rows programmatically.


To disable selection when clicking on row cells, return `false` from the `SfDataGrid.onSelectionChanging` callback. This will disable selection for row cells.


For your reference, we have provided a simple sample that demonstrates this approach. In this sample, you can select rows exclusively through the checkbox, and tapping on row contents allows you to navigate to another page. Please review the sample below for further details.


Regards,

Tamilarasan


Attachment: Sample_d9d8a84.zip

Marked as answer

JK Jacqueline Koo replied to Tamilarasan Paranthaman October 21, 2023 12:31 AM UTC

Thank you so much!!



TP Tamilarasan Paranthaman Syncfusion Team October 23, 2023 06:41 AM UTC

Hi Jacqueline,

If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you.


Regards,

Tamilarasan



MS M Sayed Qazizadah (NAMNA) January 22, 2024 09:35 AM UTC

Tamilarasan Paranthaman is true.!

Loader.
Up arrow icon