Restoring default state

2 posts, 0 answers
  1. Andy
    Andy avatar
    32 posts
    Member since:
    Nov 2010

    Posted 11 Mar 2020 Link to this post

    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.
  2. Viktor Tachev
    Viktor Tachev avatar
    2497 posts

    Posted 13 Mar 2020 Link to this post

    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:




    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.


    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.
Back to Top