start setting not restored from state with serverSide?
start setting not restored from state with serverSide?
Hello there,
I have a page with a dataTable that uses stateSave, serverSide and ajax. It looks like the selected page is not restored when the page is reloaded.
As an example: I load the page with the dataTable that will have let's say 200 rows, displayed 10 rows per page. Afterwards I click page 5 and I can see the proper start setting being successfully updated in the session storage where the state is being saved. But then, if i reload the page I am back to page 1 (not page 5) and the start setting in the state object is back to zero. Please note that column sorting, filtering and lengthMenu selections are correctly reset as they where before the reload, only the page (and the start setting by the way) is not.
Please find below my code:
$('#mytable').DataTable({
"stateSave": true,
"stateDuration": -1,
"deferRender": false,
"serverSide" : true,
"processing" : true,
"rowId": 'idcompetitor',
"searchDelay" : 500,
"dom": 'lfrtip',
"lengthMenu": [ 10, 25, 50, 100, 500 ],
"ajax": {
"url" : "ajax/getCompetitors.php",
"type" : "GET"
}
});
Has anybody faced an issue like this and can share an hint?
Thanks a lot!
Answers
Seems to work correctly with this test case I built:
http://live.datatables.net/qaqufigu/1/edit
Reloading the page goes to the page I was viewing. Does this example work for you?
What version of DT are you using? Feel free to update the example with more specific code and version you are using.
Otherwise maybe you can post a link to your page.
Kevin
Got the same problem, we already asked allan about it.
https://datatables.net/forums/discussion/44394/server-side-pagination-problem#latest
Cheers
Hannes
Thank to both of you I could figure out that it looks like the problem is with responsive indeed! Sorry, I did not mention that I was using that extension because I thought it was not relevant.
Anyway, I edited @kthorngren test case adding and enabling the responsive ext:
http://live.datatables.net/sexuqeyi/1/edit
@btree
this bug has not been fixed yet, or did I miss something?
Cheers,
Giorgio
It does indeed appear that Responsive is causing this - thanks for the test case. You are correct, the bug has not been fixed yet.
Allan
Looks like it was introduced by this commit. I've resolved it with this change. It will be in the nightly builds shortly.
Regards,
Allan
Thanks @allan tested your changes on my local environment, works fine now for me.
Cheers
Hannes