Save pagination with cookies
Save pagination with cookies
WebDev
Posts: 21Questions: 0Answers: 0
I am trying to set up a scenario where a user can go to some page on a DataTable after page 1 and when they then go to a new page and the same DataTable appears it will remember what page they had been on before. Setting "bStateSave" to "true" doesn't seem to do that. I am using the jQuery cookie plugin for some other things on this project so perhaps somebody knows a way for me to combine the two?
I'll try to post an example at DataTables Live if anyone deems it necessary but the code on this project is all over the place in many different files.
I'll try to post an example at DataTables Live if anyone deems it necessary but the code on this project is all over the place in many different files.
This discussion has been closed.
Replies
Allan
UPDATE: It seems to work sporadically off an on for different elements. Since it does work some of the time I'm not sure how to change the code to make it work all the time.
{"iCreate":1353958066655,"iStart":0,"iEnd":10,"iLength":10,"aaSorting":[[1,"desc",1]],"oSearch":{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},"aoSearchCols":[{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true}],"abVisCols":[true,true,true,true]}
http://live.datatables.net/uqacix
When any option beyond 10 is picked it goes to the details page for that option but we need the DataTable on the new page to show the page the selected option had been selected from.
It is iStart:
> "iStart":0
Thank you for the test case although it doesn't actually appear to do anything for me? Clicking around it doesn't do anything.
One key thing here is that Cookies are limited to for 4KiB and DataTables will remove cookies that go over that limit (otherwise you'd get a server error). It might be that you'd be best switching to use localStorage rather than cookies: http://datatables.net/blog/localStorage_for_state_saving - DataTables 1.10 will do localStorage by default.
But beyond that we'd need a working test case showing the issue I think.
Allan