Angularjs dataTable stateSave not woking on change routes

447 views Asked by At

I'm using AngularJS datatable and enable save state with .withOption('stateSave', true).

when I refresh the page, everything works fine But when I change routes, and came back, stateSave not working.


I found that, At each route change, datatable create a localStorage to save current table state with difference key! so when change route, saveState not working.

How can I solve the problem?

2

There are 2 answers

0
Rosty Kerei On

Just add an id attribute to the <table> element, like <table id="xxx" datatable>.

0
Sajeeb Chandan Saha On

Add an attribute id into the table. And add the following code into your angularjs controller

$scope.vm.dtOptions = DTOptionsBuilder.newOptions()
    .withOption('stateSave', true);