Loading persisted state refreshes data

2 posts, 0 answers
  1. Joel
    Joel avatar
    2 posts
    Member since:
    Jun 2012

    Posted 02 Aug 2016 Link to this post

    var grid = $(ViewModel.gridName()).data("kendoGrid");
    //Reset all existing sorts/filters first.  If the persisted view didn't have them set, the 
    //existing state and persisted state are merged.


    I'm using the setOptions method to restore the state previously obtained from grid.getOptions().  My data is small enough that I load it completely client side.  When I call set options, the grid reloads the data from the server.  It works fine, but it's unnecessary.

    Is there an option to avoid reloading the data from the server after setOptions is called?

  2. Dimiter Topalov
    Dimiter Topalov avatar
    628 posts

    Posted 04 Aug 2016 Link to this post

    Hi Joel,

    When the setOptions() method is called, the Grid is destroyed and recreated. If the widget is bound to remote data, a new read request will be made:


    There are couple of workarounds to avoid multiple calls:

    1) You can retrieve the data independently from the Grid (e.g. via $.ajax()), and store it in a variable, then bind the Grid to this array instead of to the remote service:


    2) If the Grid is loaded with the saved settings on page load, you can initially configure it with autoBind: false, and then remove the autoBind property from the options object, before passing it to the setOptiions() method. This approach will ensure that only one read request is fired (after the call to setOptions()), but is applicable only if the Grid data is not supposed to be used before the call to setOptions() (for example when the Grid is loaded on page load with different settings, based on the current user).

    I hope this helps.

    Dimiter Topalov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top