Morteza QorbanAlizade
Morteza QorbanAlizade

Reputation: 1550

Angularjs dataTable stateSave not woking on change routes

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?

Upvotes: 2

Views: 472

Answers (2)

Sajeeb Chandan Saha
Sajeeb Chandan Saha

Reputation: 865

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

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

Upvotes: 1

Rosty Kerei
Rosty Kerei

Reputation: 1034

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

Upvotes: 0

Related Questions