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

The grid is NOT kept the current behavior after filter (expand or collapse)

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Khanh
Top achievements
Rank 1
Khanh asked on 09 Aug 2018, 08:05 AM
I have a gird and child expand row. When i filter gird, the row is collapse. How to keep expand or collapse ?

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 13 Aug 2018, 09:38 AM
Hi, Khanh,

The default state of the Kendo UI Grid with detail template is collapsed to ensure better performance by means of lazy loading the details. When the master grid is refreshed, it assumes its default state and this is what happens when the grid is filtered - it is refreshed and the detail rows collapsed. 

To persist the expanded/collapsed state of the grid, you may use the approach we have shared in the documentation:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/state/persist-expanded-rows

Let me know if you have any questions in regards to the article.

Kind Regards,
Alex Hajigeorgieva
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.
Patrick
Top achievements
Rank 1
commented on 22 Feb 2022, 04:23 PM

Hey, I like this solution and it works great if you have one child element. Can you explain or show me how you would keep all rows expanded if you have a detailInit inside of a detailInit?

For the example, you have Level1 -> Level2 and you keep the expanded rows open.

What if we there were 4 levels? Level1 -> Level2 -> Level3 -> Level4.

Each row had a drop down that opened more and I wanted to keep them all expanded?
Georgi Denchev
Telerik team
commented on 24 Feb 2022, 01:08 PM

Hello, Patrick,

With multiple levels of hierarchy you'll need to extend the logic a bit.

First define two arrays that will hold the indexes of the expanded rows for the child(second level) and grand child(third level) grids.

When the refresh button is clicked, find the expanded rows in each sub grid. If the rows are part of the second level, save their indexes in the first array. If they are part of the third level then save the indexes in the second array.

Then attach a dataBound event to the second and third level grids. When the dataBound event is fired, locate the rows of the corresponding grid by using the indexes and expand these rows.

You can repeat the same process for as many levels as you want, simply declare a new array and extend the conditional statements.

Updated Dojo:

https://dojo.telerik.com/@gdenchev/oBUCECuF 

Best Regards,

Georgi

Tags
Grid
Asked by
Khanh
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or