Sfdatagrid Checkbox and consider the same id value

I have this data table and at the last column I added the selection or checkbox.

What I want to do now is that, every time I check or uncheck those box it will consider the Id. 
An example, I check the 1st item and this has an id value =1. The system will iterate all over the Id column and find the matching value and check/uncheck in selection column. 
if row 1, Selection is checked this will include row 2,6 and 7.

Id          Created By     Modified By          Item 1               Properties          Selection(checkbox)

  1              Mark               Zed                         Apple               Red
  1            Mark               Zed                         Apple               Red
  2            Joseph            Claire                      Orange             Orange
  3             Luke               Mark                       Grape               Green
  3             Luke               Mark                        Grape               Green
  1             Mark               Zed                         Apple               Green
  1            Mark               Zed                         Apple               Green

3 Replies 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team April 20, 2021 11:04 AM UTC

Hi Mark, 
 
Thanks for contacting Syncfusion support.  

You can achieve this changing the Selection column value of the other rows by using SfDataGrid.GridCellCheckBoxClick event as shown below. 

Code example :  

this.sfDataGrid1.CellCheckBoxClick += SfDataGrid1_CellCheckBoxClick; 
 
private void SfDataGrid1_CellCheckBoxClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellCheckBoxClickEventArgs e) 
{ 
    if(e.Column.MappingName == "Selection") 
    { 
        var id = (e.Record as DataRowView).Row["Id"]; 
 
        this.sfDataGrid1.View.Records.Where(x => (x.Data as DataRowView).Row["Id"].ToString() == id.ToString()).ForEach(i => (i.Data as DataRowView).Row["Selection"] = e.NewValue); 
    } 
} 


Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 


Marked as answer

MJ Mark Jayvee April 25, 2021 10:08 AM UTC

Thank you above code meets my requirements.




MA Mohanram Anbukkarasu Syncfusion Team April 26, 2021 06:10 AM UTC

Hi Mark, 

Thanks for the update.  

We are glad to know that the provided solution worked at your end. Please let us know if you require further assistance from us. We are happy to help you.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon