After carefully following the guidelines provided in the documentation for persisting the filter state, I encountered an issue. Despite successfully restoring the table state, including the filters, upon reloading the page, the <select>
box appears empty, although the filter functionality is still operational.
Fortunately, the text filter continues to function effectively.
Version Information: Angular 1.4.7 Smart-table 2.1.5
You can access the Plunker example through the following link: https://embed.plnkr.co/fK6WfZSZrgSeIG732R2X/
.directive('stPersist', function() {
return {
require: '^stTable',
link: function(scope, element, attr, ctrl) {
var nameSpace = attr.stPersist;
//save the table state every time it changes
scope.$watch(function() {
return ctrl.tableState();
}, function(newValue, oldValue) {
if (newValue !== oldValue) {
localStorage.setItem(nameSpace, JSON.stringify(newValue));
}
}, true);
//fetch the table state when the directive is loaded
if (localStorage.getItem(nameSpace)) {
var savedState = JSON.parse(localStorage.getItem(nameSpace));
var tableState = ctrl.tableState();
angular.extend(tableState, savedState);
ctrl.pipe();
}
}
};
});;