Issue with selected rows when reloading DataGrid (StateHasChanged)

Hey guys,
I've got the following setup:

I am using the RadzenDataGrid with selectedRows as bind-value.

The problem I am facing is, that the data of the grid is dynamically provided by a service.
Now, everytime the data of the Grid gets updated (invoking "StateHasChanged") the selection is tecnically still present(in the selectedRows list) but the visual effect of the selected rows is lost (rows unmarked and checkboxes unchecked).
I guess it is due to the fact the effects are tied to the RowSelect event and this is not fired on rerender because tecnically the rows are already selected?

I would appreciate any help to fix this. :slight_smile:

Most probably the data items hash code is different - you can set KeyProperty in such cases:

Thank you very much enchev!
Using the KeyProperty resolved the problem with highlighting the rows, but the checkboxes (Blazor DataGrid multiple selection) still remain unchecked. Furthermore they are now not clickable anymore if the row is highlighted and the checkbox unchecked. :thinking:
Do you happen to have any Idea on that?

You need to update the code behind the checkboxes to check if the item is selected by key value.

Ah, I see. Thanks alot!

I'm sorry to bother you again, but I encountered another issue I am unable to fix:

When setting KeyProperty the rows get visually reselected (highlighted) just fine, but the whole row becomes unclickable (not just the checkboxes) until the selectedRows is cleared, e.g. throug another button.
Note, that AllowRowSelectOnRowClick ist set to true, and right clicking (context menu) still works.