[Grid]: Multiple selection and paging not work togehter
I have a Grid with AllowPaging, AllowSelection, and SelectionMode="GridSelectionMode.Multiple". I configured a DataProvider for client-side mode.
Selection and paging work, but when I select some items and then change the page, the selection is cleared. I tried storing SelectedItems in a local variable, but that didn't help.
I also noticed that every time I change the page, the SelectedItemsChanged function is called. So, in that function I added something like:
if (items is not null && items.Count > 0)
{
foreach (var item in items)
{
if (!SelectedItems.Any(s => s.Id == item.Id))
{
SelectedItems.Add(item);
}
}
}
to keep the selected items, but if I change page in a one with items selected, in the Grid those are non seletect.
I try also
private async Task<GridDataProviderResult<MyItem>> TableItemsResultDataProvider(GridDataProviderRequest<MyItem> request)
{
var result = await Task.FromResult(request.ApplyTo(TableItems));
itemsGrid.SelectedItems = SelectedItems;
return result;
}
But items alread not selected.
The problem is present also in this page. Try to select some items and than change page.