This is a migrated thread and some comments may be shown as answers.

Persist State - Kendo Grid Using angular js

5 Answers 263 Views
Grid
This is a migrated thread and some comments may be shown as answers.
developer
Top achievements
Rank 1
developer asked on 25 Aug 2016, 11:33 AM

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.

5 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 26 Aug 2016, 07:13 AM
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.
 
0
developer
Top achievements
Rank 1
answered on 26 Aug 2016, 10:19 AM

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

 

0
Konstantin Dikov
Telerik team
answered on 26 Aug 2016, 11:55 AM
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.
 
0
developer
Top achievements
Rank 1
answered on 26 Aug 2016, 12:13 PM

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

Here is the code that extracted in class


Admin: Removed code as per client request

0
Konstantin Dikov
Telerik team
answered on 30 Aug 2016, 08:13 AM
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.
 
Tags
Grid
Asked by
developer
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
developer
Top achievements
Rank 1
Share this question
or