lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

How can I select page and sort manually with server side pagination ? #739

Closed johnico closed 7 years ago

johnico commented 7 years ago

Hi . im using smart table with pagination in server side. I am keep the sorting and pagination details in local storage or url , my question is how can I keep the page when the user was and when he will come back with the specific url or just back to the page he will get the same page he was.? the same issue is with Sorting, How can I sorting by url parameter how can I do that, ?

thx for the help

MrWook commented 7 years ago

Hello @johnico,

i don't think that this have something to do with the SmartTable itself so this forum isn quite the right place for this kind of question. It's more a general javascript/angular question how you put an object into the URL or into the local storage.

Put i try to help you anyway: Localstorage: You can put something into the localstorage with: localStorage.setItem('tableState', JSON.stringify(tableState)); SolocalStorage.setItem() set a new object (JSON.stringify(tableState)) into the localStorage. tableState need to be stringify because you can only save a String or a number.

In Tablestate is the sorting, pagination and searching for the SmartTable so if you use one of those three you save it in the localstorage and when you load the page you check if there is content in the localstorage for tablestate and trigger the smarttable with the saved tablestate Kind of this this.callServer = function callServer(tableState) { //....do some stuff....

//check for localStorage tablestate if(localStorage.tableState !== undefined){ tableState = JSON.parse(localStorage.tableState); } SmartTable_pipeline.getPage(tableState, $scope.options).then(function (result) { //....do some more stuff....

//safe into localStorage localStorage.setItem('tableState', JSON.stringify(tableState)); }); }; This could work i don't know i didn't test it.

I can't help you with the URL part i don't use the URL to provide the user data but i think you can get parameters over the URL with '$_GET' in PHP