Saving and loading state of sub-grids?

1 Answer 147 Views
Grid
Rudolf
Top achievements
Rank 1
Rudolf asked on 10 Nov 2021, 01:21 PM

We have successfully implemented saving the state of our custom component main grid with browser local storage, using this example.

 

We have sub-grids in the main grid via the DetailTemplate section, for example:

<TelerikGrid Data="@Data"
             @ref="@GridReference">
    <DetailTemplate>
        @{
            var ctx = context as ExpandoObject;
            <CustomSubgrid Context="@ctx" Property="Expanded" @ref="@SubGrid"></CustomSubgrid >
        }
    </DetailTemplate>

 

Each page using the custom main grid has a unique state storage key - e.g.:

StateStorageKey="ThisPage_MainDynamicGrid"

Is it possible to do a similar saving and loading of the sub-grids states, if they are dynamically loaded via the DetailTemplate?

Rudolf
Top achievements
Rank 1
commented on 10 Nov 2021, 01:32 PM

I may add that we would like to implement it as a one-button solution, so part of the current Save & Load State buttons for the main grid.

1 Answer, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 11 Nov 2021, 09:10 PM

Hi Rudolf,

You can hook to the OnStateChanged and OnStateInit events of all grids and use lambdas to build unique and logical identifiers for their state. For example, the child grid can use the primary key of the parent row as part of the storage key.

With this, there is no need to have buttons at all.

If you want to do this on button clicks, though, things can get complicated as you will need to manage references to the child grids dynamically, and that's a little tough in Blazor.

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/.

Rudolf
Top achievements
Rank 1
commented on 12 Nov 2021, 10:59 AM

Thank you for the feedback. We have decided to do it with the events as mentioned for now, and remove the buttons. We'll revisit the buttons and references to the child grids etc. later.
Tags
Grid
Asked by
Rudolf
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or