Persist State - Kendo Grid Using angular js

6 posts, 0 answers
  1. developer
    developer avatar
    58 posts
    Member since:
    Nov 2015

    Posted 25 Aug Link to this post

    When I'm using Angular Grid I'm getting an error in console  each time the grid loads as "Cannot read property 'removeClass' of null"  .This was getting in the console when I use persist state for grid.

    I'm using set options method to set local storage data to grid.

     
      var options = localStorage"departmetsOptions"];
       var response = JSON.parse(options);
       $scope.departmets.setOptions(response);
    Here the "setOptions" method is internally calling read method and it is throwing the above exception. Is there any other method to persist the state of grid so that we can avoid this console error.

    Please assist to fix the issue.

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 26 Aug Link to this post

    Hello,

    In the following dojo example you will notice that retrieving the options with getOptions method, stringifying the JSON, parsing it back to JSON and passing it to the setOptions method works correctly, without any errors:
    Could you please create a dojo example replicating the error, so we can test it locally and see if we can pinpoint the root of the problem. Meanwhile, you can take a look at the following forum thread, where the same error is discussed:

    Best Regards,
    Konstantin Dikov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. developer
    developer avatar
    58 posts
    Member since:
    Nov 2015

    Posted 26 Aug in reply to Konstantin Dikov Link to this post

    Thank you for the response Diko.

    In my case I'm saving the grid state in local storage  while navigating to other page and loading the persist state when i come back to same page using data bound function and setting the grid with saved options using gridname.setOptions().

    here is the example DOJO

    in DOJO setOption method it self is trowing error.

     

    Please assist to fix the issue

     

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 26 Aug Link to this post

    Hello,

    When you call the setOptions method within the dataBound event, this will cause endless recursion (if you wrap the function in a setTimeout) or in your scenario, it will break the initialization of the widget. You should load the saved state of the Grid only once, when the Grid is initialized. One option is to use global flag variable and use it for calling the setOptions method only initially, as in the following dojo example:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  6. developer
    developer avatar
    58 posts
    Member since:
    Nov 2015

    Posted 26 Aug in reply to Konstantin Dikov Link to this post

    Hi..
    Thank you for your reply,
    I'm abstracted grid code and reusing where ever it require.and i'm doing the same as u explained.here grid is initializing two time

    Here is the code that i extracted in abstact class


    Admin: Removed code as per client request

  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 30 Aug Link to this post

    Hi,

    When you call the setOptions method, the Grid will be re-initialized, so it is expected that the widget will be initialized two times: the initial initialization and the one initiated by the setOptions method.


    Regards,
    Konstantin Dikov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top
Kendo UI is VS 2017 Ready