Table selection is reset after ReloadData() #3167
-
I have some dynamically changing data I want to display in the Table-component. I'm also using a selection column to allow a user to select rows and then perform actions on them. My problem is that the selection is reset after calling ReloadData() on the table. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I didn't bother reading through the source code, but it appears that when you set up your selection-column you use a unique string as a key like so `
` |
Beta Was this translation helpful? Give feedback.
I didn't bother reading through the source code, but it appears that when you set up your selection-column you use a unique string as a key like so
<Selection Key="@context.Id"/>
, but internally in the component it will use the object-reference to see if the object is still in both SelectedKeys and in the Data. This means that when I refresh data in the background the table will remove the selection because now there are new objects (though with the same keys).I got this to work by in the HandleTableChange event after loading my data then setting the selectedRows with the new objects
`
async Task HandleTableChange(AntDesign.TableModels.QueryModel queryModel)
{
var _data = read_my_data_he…