Completed
Last Updated: 23 Jan 2020 12:02 by ADMIN
Morten
Created on: 10 Jun 2015 14:11
Category: Grid
Type: Feature Request
7
save/restore grid USER state
The current implementation of Persist State http://demos.telerik.com/kendo-ui/grid/persist-state isn't meant to save the user state of the grid.

Let me explain.
Currently setOptions() override the options in the grid. That has a rather unfortunate side effect. The Column[{...}] options coming from the server is no longer used (ever) as all column options are now coming from the client. Effectively overriding all column options.

Example:
{
   ...,
   columns: [
      { field: "Name", filterable: false }
   ]
}

This is saved using the current persist state.
Later the backend now supports filtering of the "Name" field, and we change filterable to true. The user will not see this change. Because it's overridden with the column options stored on the client.

It would be nice if this wasn't the case.
Either make a new method get-/setUserOptions() or change the current get-/setOptions() (I cannot figure out the usecase for the current implementation as it to me always would be used for what I've described here - and do a poor job of it)

However we also need to recognize that different options have different life cycles.
For example would I want to save current page, sorting and filters in sessionStorage.
While column order, size and pageSize (don't override, just set. As the range can change) would be saved in localStorage.
So that need to be easy to do.

The last thing we need is an event where it would make sense to call setUserOptions(). For the purpose of loading saved state without having to click a "Load state" button. The event needs to be before the datasource is quried. 
The current dataBinding event doesn't work as it would result in an infinite loop of datasource queries.
1 comment
ADMIN
Alex Hajigeorgieva
Posted on: 23 Jan 2020 12:02

Hi, Morten,

The Kendo UI Grid offers reordering of the columns/ showing and hiding and those are user settings as well.

If I understand correctly, you would like to only restore the data source view() - the filter, sort, group, page, pageSize without a button.

If this is the case, you can

  • set the grid to be autoBind:false
  • check if there are any saved options in the local storage
  • if yes, use the dataSource query() method to add them all in a single request which will trigger a read request and show the grid with data
  • if no, then just call the read() method of the data source

To keep the desired data options, you could update the local storage during dataBound as the grid triggers dataBound each time a sort/filter/group or page is applied.

In case you have further questions or had something else in mind, please feel free to get in touch.

Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.