GridCheckBoxSelectorColumn Binding doesnt work

Dear Team, i have found another bug, this time it is very serious...
I will not ask you why such things are still left in the production, why noone is testing your code etc etc :)...

Taken directly from your "Syncfusion wpf-demos-master" project and tested with the version 20.1.0.59, the following is not working:
when i use the Selector column, the Selected property is not being updated, when the user selects an element on the grid. This is the sole purpose of this column to make things a bit funnier... Still this column doesnt work.



And the code of my test button:

var myDataContext = sfgrid.DataContext as EmployeeViewModel;

if (myDataContext != null)

{

MessageBox.Show($"You have selected {myDataContext.EmployeeDetails.Count(item => item.Selected)} grid elemenets");

}


#Edit1) Also when binding the SelectedItems property to any property in the ViewModel, it doesnt work as well. Only when accessing the property directly in the code behind it works.

#Edit2) Since the bindings dont work, there is a manual workaround, by setting the SelectedList on the ViewModel through the Grid's.SelectionChanged event. But, there is no way i found, to set the selectedItems of the grid, when loading an item again. Could you please provide me a workaround till you fix the problem with the bindings? Otherwise the whole grid is not usable at the moment when you want to select/deselect rows.


With regards
Your trusted tester
Fanourios Siskakis


3 Replies

DM Dhanasekar Mohanraj Syncfusion Team June 23, 2022 02:15 PM UTC

Hi Fanourios Siskakis,

Please find the response for the reported issues below,

Reported issue

Response

 

when i use the Selector column, the Selected property is not being updated, when the user selects an element on the grid. This is the sole purpose of this column to make things a bit funnier... Still this column doesnt work.

 


We have checked the reported issue in our end. By default, GridCheckBoxSelectorColumn is an unbound column. So, you should not get the selected item from the underlying collection mentioned in your update. However, you can retrieve the selected item using “this.sfgrid.SelectedItem”. Please check the below user guide document for more information,

UG link: https://help.syncfusion.com/wpf/datagrid/selection#programmatic-selection
 


Also when binding the SelectedItems property to any property in the ViewModel, it doesnt work as well. Only when accessing the property directly in the code behind it works.


 

We have analyzed the reported issue in our end. But we regret to let you know that the reported issue does not reproduce in our end. Here we have attached the tested sample for your reference. Please have a look on this. If you still facing the same issue, Modify the attached sample based on your scenario. It will be more helpful for us to check the possibilities to resolve the reported problem. 

 


Since the bindings dont work, there is a manual workaround, by setting the SelectedList on the ViewModel through the Grid's.SelectionChanged event. But, there is no way i found, to set the selectedItems of the grid, when loading an item again. Could you please provide me a workaround till you fix the problem with the bindings? Otherwise the whole grid is not usable at the
moment when you want to select/deselect rows.




SfDataGrid.SelectedItems is a collection property. So, whenever the SelectedItems collection is changed, the property bound with SelectedItems does not get notified for this change. However, you can achieve this by creating an attached property for SelectedItems. Here we have published the KB for your requirement.

KB link: https://www.syncfusion.com/kb/3070/how-to-bind-the-selecteditems-property-of-sfdatagrid-to-viewmodel-property

Please have a look on this and revert us if you need further assistance for this.


Regards,
Dhanasekar M.


Attachment: GettingStarted_4d862313.zip


FS Fanourios Siskakis June 24, 2022 11:11 AM UTC

I am removing my previous comment here...

I will just not respond to your comments, it doesnt worth it...

I am not going to report here anything again.

Have fun :)


DM Dhanasekar Mohanraj Syncfusion Team June 27, 2022 02:15 PM UTC

Hi Fanourios Siskakis,

We deeply regret for the inconvenience caused.


As we mentioned earlier, the GridCheckBoxSelectorColumn is unbound and do not require to bound with any properties from view model, but due to our internal structure, a dummy mapping name is needed. Mistakenly instead of dummy mapping name, a property from the underlying view model was bound in our demo application and we regret for the improper explanations in our previous update. We have updated the demo application now with removing the property binding from view model and these changes will be reflected in our upcoming Essential Studio main release which is expected to be rolled out within two weeks. 


We appreciate your understandings.

Regards,
Dhanasekar M.


Loader.
Up arrow icon