This is a migrated thread and some comments may be shown as answers.
Restoring default state
1 Answer 5 Views
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 11 Mar 2020, 08:53 PM
We are using getOptions and setOptions to allow the user to persist there current selections for column that are displayed, filters, etc.  We are reloading this persisted stated when the page loads.   How do get it to restore to the original default state?  We would like a button that causes the state to go back to the default state.

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 13 Mar 2020, 12:13 PM

Hello Andy,

 

For keeping the initial Grid state I would suggest an approach that is very similar to the one used for persisting the current state.

The default state should be persisted separately from the current state. If you are using localStorage I would suggest using a different key for the initial state.  The entries in localStorage would look similar to this:

 

localStorage["current-grid-state"]

localStorage["default-grid-state"]

 

In the document.ready() event check if there is something present in localStorage["default-grid-state"]. If the entry is null that would mean the Grid is loaded for the first time and you can save the settings there. Reloading the page should not save the settings again. 

 

As for keeping the current state you can use the approach you already have in place.

 

Give the suggestion a try and let me know how it works for you.

 

Regards,
Viktor Tachev
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
Andy
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or