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);
Please assist to fix the issue.
5 Answers, 1 is accepted
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
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
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
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
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