How to select DataGridRow only when click checkbox?

Hi~
How to select DataGridRow not by tapping DataGridRow's cell or DataGridRow.
Only want to select DataGridRow by tapping the checkbox.

I try customizing selection behavior but not work correct:


class CustomSelectionManager extends RowSelectionManager {
@override
void handleTap(RowColumnIndex rowColumnIndex) {
if(rowColumnIndex.columnIndex > 0) {
return
} else {
_dataGridController.selectedRows.add(checkboxDataGridSource.dataGridRows[rowColumnIndex.rowIndex -1 ]);
}
super.handleTap(rowColumnIndex);
}
}


I have
set propterty showCheckboxColumn:true and set selectionManager: CustomSelectionManager()



3 Replies 1 reply marked as answer

SR Sangeetha Raju Syncfusion Team December 7, 2021 06:10 AM UTC

Hi Jimmy Huang, 
 
Thank you for contacting Syncfusion support. 
 
From the provided code snippet, you have called the super.handleTap() method for all the cell tap functions. You can achieve your requirement by passing the tap function to the super method only when the RowColumnIndex.columnIndex is 0. Please refer the following code snippet. 
class CustomSelectionManager extends RowSelectionManager { 
  @override 
  void handleTap(RowColumnIndex rowColumnIndex) { 
    if (rowColumnIndex.columnIndex == 0) { 
      super.handleTap(rowColumnIndex); 
    } 
  } 
} 
 
We have prepared a sample for your reference. Please find the sample from the following link. 
 
 
Please let us know if you would require any further assistance. 
 
Regards, 
Sangeetha Raju. 


Marked as answer

JH Jimmy Huang replied to Sangeetha Raju December 7, 2021 07:19 AM UTC

Hi~  Sangeetha Raju,

Your solution works well.  Thanks for your help.





SR Sangeetha Raju Syncfusion Team December 7, 2021 01:10 PM UTC

Hi Jimmy Huang, 
 
Thank you for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you need any further assistance. As always, we are happy to help you out. 
 
Regards, 
Sangeetha Raju. 


Loader.
Up arrow icon