grid.setOptions causes empty grid

7 posts, 0 answers
  1. Jan Meinken
    Jan Meinken avatar
    1 posts
    Member since:
    Jul 2010

    Posted 19 Feb 2015 Link to this post

    Hi all, 

    in our Application we are using a normal grid. We are trying to save the Filters with the following code: 

    var grid = $("#myGrid").data('kendoGrid');

    localStorage["kendo-grid-options"] = kendo.stringify(grid.getOptions());

    This works perfectly. We are trying to reload our saved Filters with the following code: 

    var options = localStorage["kendo-grid-options"];
                if (options) {
                    grid.setOptions(JSON.parse(options));
                }

    After this our Grid is just empty... The filters are applied to the coloumns.. 
    If we click on the refresh icon on our grid or trigger the click in code ($('.k-i-refresh').trigger('click');) the filtered data appears?

    Any ideas?

    Our main target is to apply the filters on the first load.. So if we leave the page, and go back to the grid should directly display the filtered data.. But so far all our attempts failed.. 

    Regards
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 20 Feb 2015 Link to this post

    Hello Jan,

     

    I am afraid that the issue is not a known one, nor is reproducible in our online demos, so please extract a runnable sample in a Kendo UI Dojo and we will be happy to help.

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Will
    Will avatar
    34 posts
    Member since:
    Oct 2013

    Posted 10 Jul 2015 Link to this post

    This is kind of late but I was searching for problems similar to mine and this sounds like one.

    What I have found so far is that by calling the Grid's setOptions() method, some internal methods were being called more than once that shouldn't have been.  I'm guessing that setOptions() is not checking for duplicate or conflicting option settings and blindly binding to duplicate callbacks for the same event(s).

    In my case, the setOptions() call was in some obsolete code anyway so I just removed it.

     In the future, I'd try using getOptions() first and un-set anything I was aiming to set first.

    Will

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 13 Jul 2015 Link to this post

    Hello Will,

    setOptions() will extend the current options of the Grid. So it does check for duplicated options and overwrites them with the new ones.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Paul
    Paul avatar
    2 posts
    Member since:
    Sep 2013

    Posted 09 Dec 2015 in reply to Kiril Nikolov Link to this post

    Hello,

     

    I am having this exact same issue since upgrading to 2015 Q3 SP1.  I've created a dojo example using as close our MVC generated grid, and I simplified it as much as possible while still reproducing the problem.  Needed to add kendo.aspnetmvc.min.js to includes.

     If you look at the bottom of the script , the problem is reproduced:

     var grid = $('#AgentViewGrid').data('kendoGrid');

    var currOpt = grid.getOptions();
    //grid.options = currOpt;
    grid.setOptions(currOpt);

    The commented line is a workaround I found - if we explicitly set the options object first by assigning it, THEN call setOptions(), the problem dissapears.

     I don't want to go with this workaround in production, however, since I don't understand what it is doing.  Please let me know if you can determine what about our grid is keeping setOptions() from working.

     Best regards,

    Paul Haines

  7. Paul
    Paul avatar
    2 posts
    Member since:
    Sep 2013

    Posted 09 Dec 2015 in reply to Paul Link to this post

    http://dojo.telerik.com/@paul.haines@amadeus.com/AXiTO
  8. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 11 Dec 2015 Link to this post

    Hello Paul,

     

    The example that you sent is what is generated from the MVC wrappers, and therefore it is not really one that can be used for investigation. This is why I have created an example, where the issue was not reproduced, please check it out and edit it in order to show the issue and we will be happy to help:

     

    http://dojo.telerik.com/iBIHu

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready