Kendo MVC Grid - Preserve State issue

2 posts, 0 answers
  1. Tejas
    Tejas avatar
    73 posts
    Member since:
    Mar 2011

    Posted 22 Sep 2015 Link to this post


    We are trying to implement kendo grid preserve state functionality. Requirement is a grid state (filter, page etc) is already pre saved in the db and every times page loads, we have to show grid with the pre saved state. We followed the example given in link ( ) and able to achieve the requirement in two steps.
     Step 1: Load the page with default grid option

          .DataSource(ds => ds.Ajax().Read("Read", "Home"))
          .Reorderable(r => r.Columns(true))
          .Resizable(r => r.Columns(true))

    and then,
    Step 2: on document ready, make an ajax call , get the pre saved grid options , destroy the existing grid and set the grid options

    $(document).ready(function ()
        var grid = $("#grid").data("kendoGrid");

        var dataSource = grid.dataSource;

            url: "/Home/Load",
            success: function(state) {
                state = JSON.parse(state);

                var options = grid.options;

                options.columns = state.columns;

                options.dataSource.pageSize = state.pageSize;
                options.dataSource.sort = state.sort;
                options.dataSource.filter = state.filter;



    Problems with this approach are

    - grid’s data read server side method “Read” is hit twice. One for default load and other for state load.
    - Grid shows all records first , then truncates and then shows the data with saved grid options. It does not look good.

    Is there any way to apply the grid options first time itself, not on document ready. I want to avoid multiple server side calling and grid data reads.
  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    2033 posts

    Posted 24 Sep 2015 Link to this post

    Hello Tejas,


    There are couple of possible solutions/ideas for your scenario: 


       1. Is there a particular reason why the Kendo UI Grid is not initialized after the state options are retrieved from the server? Why the Kendo UI Grid for ASP.NET MVC is declared with some default options at first place and then destroyed in order to load the state options. The Kendo UI Grid could be initialized on the client-side in the document ready after the response with the state options is retrieved. 


       2. In order to avoid the initial request to the read method you can set the AutoBind(false) for the Kendo UI Grid for ASP.NET MVC. Please check the autoBind option. 


      3. Also an option would be to use a Model object for setting the columns configuration options and etc just like shown in the Binding to DataTable code library. A model object is used to add columns and some other configuration options. 


    Boyan Dimitrov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top