Declined
Last Updated: 25 Aug 2022 06:14 by ADMIN
Arash
Created on: 15 Aug 2022 19:09
Category: Grid
Type: Bug Report
0
Selected items issue in manual binding mode

Hi,

We ran into an issue with manual binding and selected items with Grid component. I used the 'WebApiFromServerApp' sample in 'grid\datasourcerequest-on-server' folder from Telerik's samples on GitHub.

To recreate the issue, modify 'GridWithService.razor' file in 'WebApiFromServerApp' project. I attached modified project.

To test the behavior: 

  1. Select records with Id 2 and 3 from grid.
  2. Navigate to another page and return back to the first one.
  3. Despite selected items exist in the grid's 'SelectedItems', but they are not being shown. This is the first issue.
  4. The second issue is you can still select them again! In that case they would be duplicated as selected items.

Thank you.

 

 

 

 

3 comments
ADMIN
Dimo
Posted on: 25 Aug 2022 06:14

Hello Arash,

In this case, I can only suggest to preserve and maintain the selected items manually. For example -

  • Use the SelectedItemsChanged event to know which are the selected items.
  • When the Grid rebinds as a result of paging, filtering, etc., reset the SelectedItems parameter inside the OnRead handler, based on the stored old selected item IDs.

Regards,
Dimo
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Arash
Posted on: 24 Aug 2022 23:36

Hi Dimo,

The problem is our grid is bound to the list of ExpandoObject object.

private List<ExpandoObject> GridData { get; set; }

Since ExpandoObject is sealed we can't derive and override Equals() method. 

 

Regards

ADMIN
Dimo
Posted on: 19 Aug 2022 07:56

Hi Arash,

The observed behavior means that the row instances (object references) change on every Grid rebind. That's why the Grid cannot map the selected row objects in the SelectedItems variable to the items in the current data collection (args.Data).

In your case, override the Equals() method of the Grid Model class, so that .NET compares the rows by their unique IDs, and not by their object references.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.