Hierarchical grid structure and OnStateChanged

1 Answer 193 Views
Grid
Peter
Top achievements
Rank 1
Peter asked on 16 Jun 2021, 08:55 AM

I've got a hierarchical grid structure and I want to use the OnStateChanged event in the (0...N) child grids and do things with the state of the grid that has changed, but it seems impossible because there doesn't appear to be a way to work out which child grid is firing the event.

Within OnStateChangedHandler(GridStateEventArgs<T> args), args doesn't contain a reference back to the grid that's changed.
Obviously the top-level parent grid is easy enough, but I'm completely stumped with the children...

Has anyone succeeded in doing this?

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Jun 2021, 06:08 PM

Hi Peter,  

I think the way to solve this is to use a lambda expression to pass more arguments to your handler that will identify the grid you want to work with. This will probably apply to the OnStateInit event as well. You can use the context of the DetailTempalte to uniquely identify the model that this grid is a child of to know what to save/load. You can find similar examples here (they are for editing but the concept is the same).

Regards,
Marin Bratanov
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/.

Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or