Persist state - data source urls

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    2 posts
    Member since:
    May 2011

    Posted 21 Apr 2015 Link to this post


    We are using the grid getOptions/setOptions to persist the users filters, column settings etc to a cookie

    An issue we now have is it seems to persist everything including the datasource urls for read/update. This is an issue for us as we use custom MVC routes which look something like this: /jobs/1234/deliverable so the id is embedded into the url. When this is persisted the grid ends up querying data for a previously used Id.


    What is the best way to prevent persisting the datasource url information and always use the URL as defined in the html page?

    We have managed to get it working by doing this:

    function loadGridState(grid, sessionKey) {
        var options = localStorage[sessionKey];
        if (options) {
            var parsedOptions = JSON.parse(options);
   =; //dont persist datasource urls


    Is there a better way to do this and is there anything else we should be preventing (e.g. update, delete) if this were to be a generic function for the entire project?


    One other strange we noticed is the object stored from getOptions is a slightly different structure to that directly on the grid.

    E.g. the Grid has but the getOptions stores




  2. Dimo
    Dimo avatar
    8478 posts

    Posted 24 Apr 2015 Link to this post

    Hi Andy,

    If the stored Grid options should be modified before being used, then you should do exactly what you are doing now - manually tweak values in the settings object before using setOptions(). is an internal merged object of the default transport's read prototype values and the values in the Grid configuration (returned by getOptions() ) provides the proper structure, which matches the Grid dataSource configuration API and is suitable for initializing a Grid dataSource transport instance.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top