Saving custom settings of the grid

4 posts, 0 answers
  1. Andrey
    Andrey avatar
    9 posts
    Member since:
    Apr 2016

    Posted 29 Apr 2016 Link to this post

    Hello!
    I know that user can save grid settings as per http://demos.telerik.com/kendo-ui/grid/persist-state
    But it saves all settings. Is there a way to save a selected number of settings?
    For example I want to save Sorting, Columns widths and Columns order.
    Can this be done via some configuration? If no, can someone give an example how to implement it for localstorage?
    Thanks!
  2. Andrey
    Andrey avatar
    9 posts
    Member since:
    Apr 2016

    Posted 30 Apr 2016 in reply to Andrey Link to this post

    No one? Maybe Telerik support has something to say? We use the paid version of Kendo in our project if that matters.

    Also I think there's a bug with `grid.getOptions()` because it save the data source! And if your data source is set dynamically and you get the new data and then click Load State it will load the data from the old source. That not what the user want, right? They just want their grid settings - ordering, sorting, widths etc.
  3. Stephen
    Stephen avatar
    90 posts
    Member since:
    Jan 2011

    Posted 02 May 2016 in reply to Andrey Link to this post

    You have to take what you want from getOptions() and discard what you don't want.  getOptions() literally returns all the current options of the grid that it uses to function internally...i.e. it is simply a public helper method to return what is essentially private data.

    My post in http://www.telerik.com/forums/problem-with-saved-states explains what I do with it.

     

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 03 May 2016 Link to this post

    Hello Stephen,

     

    Indeed in case of using local data binding the getOptions() method will return the data along with the data source settings. As Andrey suggested in this case the data should be removed from the JSON object returned by the getOptions() before passing to the setOptions().  

    var options =grid.getOptions();
    //it can be set to either null or emprty array []
    options.dataSource.data = null;

     

     

    Regards,
    Boyan Dimitrov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top