How to programmatically check/uncheck a check box that is in a row of the SfDataGrid?

Greetings!

I have an SfDataGrid displaying details of Jobs and one of its autogenerated columns is a CheckBox column. The checkboxes are set to checked or unchecked based on a bool (jobFavorite) that is a property of a Job. An ObservableCollection of Jobs is set as the grid ItemSource. When I change the jobFavorite bool in one of the ObservableCollection's jobs, the corresponding CheckBox in the grid does not reflect the change.

The only way that I was able to make the grid reflect the change was by setting its ItemSource to null and then setting it again to the ObservableCollection of Jobs. However, doing this causes the "Checked" event handler for the row in question to fire 3 times in succession as if the CheckBox was clicked 3 times. So while the grid does reflect the change of the bool by using this method, the 3 calls to the "Checked" event handler caus issues because that event handler does things which should not be happening unless the check box is actually checked with the mouse.

I hope this all makes sense :-)

Thank your for your time in advance.
Jacob



3 Replies 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team April 20, 2021 01:18 PM UTC

Hi Jakub, 

Thanks for contacting Syncfusion support.  

You have to implement INotifyPropertyChanged interface and raise PropertyChanged for the JobFavourite property. Please refer the sample from the following link. 


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

Regards, 
Mohanram A. 


Marked as answer

JA Jakub April 20, 2021 01:33 PM UTC

Thank you very much Mohanram!

Have a nice day :-)


MA Mohanram Anbukkarasu Syncfusion Team April 21, 2021 04:50 AM UTC

Hi Jakub, 

Thanks for the update.  

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

Regards, 
Mohanram A. 


Loader.
Up arrow icon