This is a migrated thread and some comments may be shown as answers.

Restore selected/expanded row under column grouping

1 Answer 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kun
Top achievements
Rank 2
Kun asked on 21 Mar 2019, 09:00 AM

Hello,

I've posted a thread about save/restore row 2 months ago. It worked great until I grouped a column.

When a column is grouping, the row index that I save/restore is the index in the grouping zone where the row located. When I load this row index to the gridview, every grouping zone will take over this row index. For example if I save a selected row, when I reload its index, all rows which has this index in every grouping zone will be selected.

 

If you would like to test, check out the demo in my old post (Hristo's answer):

https://www.telerik.com/forums/restore-selected-tab-in-hierarchy-child-page-view-after-data-refresh

 

Thank you by advance for your help.

Regards,

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Mar 2019, 12:16 PM
Hello, Kun, 

I have tested the sample project from the referred feedback item. Note that RadGridView exposes two collections that contain data rows:

- Rows - contains all data rows that belong to RadGridView. Data operations such as grouping, sorting, filtering, etc. do not change the content of the collection or the order in which the row objects exist in the collection.
- ChildRows - returns the data rows that are currently represented by RadGridView in the order in which they appear. The collection is modified every time a data operation (grouping, sorting, filtering) occurs.

The Index property of the row uses internally the ChildRows collection of the respective parent to give you index. When you group the grid, a new level will be created for the groups and the index will be different since the ChildRows collection will be changed.

The possible solution that I can suggest is to store the GridViewRowInfo instance itself, not the index. Thus, once you store the expanded row objects, you can traverse the rows recursively and check whether the current row is already stored in the expanded collection and this restore the expanded state. Thus, you will not be worried about the grouping, filtering or sorting index changes that may occur.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Kun
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or