Saving the page of the datatable on page refresh
Saving the page of the datatable on page refresh
Hi I am using jQuery datatable ver 1.8.0 and having hard time saving the pagination on page refresh. In other words, if I am on page 5 and I refresh the browser (F5) , I want the table to start from page 5 which is not happening, no matter what I do.
Note that I am using server side processing i.e. bServerSide = true;
Below is the code snippet that I think is relevant
fnServerData": function ( url, data, callback, settings ) {
var loadPageAt= trainList.fnSettings()._iDisplayStart;
alert(loadPageAt);
data.push( { "name": "iDisplayStart", "value": loadPageAt} );
settings.jqXHR = $.ajax( {
"url": url,
"type": "POST",
"data": data,
"success": function(json) {
userListTable.fnSettings()._iDisplayStart = json.iDisplayStart;
callback(json);
}
}
Note that when I click to a certain page number (assume iDisplayLength 10) , the alert in the code give me the right value i.e. if I click on page 5 - 40 is alerted. However, at this point, if I refresh, the alert value is now 0.
Please advise.
Note that I am using server side processing i.e. bServerSide = true;
Below is the code snippet that I think is relevant
fnServerData": function ( url, data, callback, settings ) {
var loadPageAt= trainList.fnSettings()._iDisplayStart;
alert(loadPageAt);
data.push( { "name": "iDisplayStart", "value": loadPageAt} );
settings.jqXHR = $.ajax( {
"url": url,
"type": "POST",
"data": data,
"success": function(json) {
userListTable.fnSettings()._iDisplayStart = json.iDisplayStart;
callback(json);
}
}
Note that when I click to a certain page number (assume iDisplayLength 10) , the alert in the code give me the right value i.e. if I click on page 5 - 40 is alerted. However, at this point, if I refresh, the alert value is now 0.
Please advise.
This discussion has been closed.
Replies
Allan
I'd suggest removing the iDisplayStart stuff from fnServerData and seeing if the built in state saving does the trick for you. If not, can you link us to a test case showing it not working?
Allan
> I am thinking, the jQuery Datatable on tear down set the iDisplayStart to 0.
Tear down as in fnDestroy? Yes it does. Are you making that call?
Allan