I'm trying to make sure state of a DataTable is saved in a cookie so when page is reloaded it maintains the sort order of fields. This is my code, but bStateSave seems to be having no effect whatsoever.
I followed the method described here: .html.
What am I doing wrong? Will appreciate help!
tbl = $(selector).dataTable({
"bStateSave": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": dataSource,
"iDeferLoading": totalRecCount,
"sDom": layout ? layout : defaultLayout,
"fnDrawCallback": drawCallback,
"aoColumns": aoColumns,
"oLanguage": {
"sSearch": ""
}
});
I'm trying to make sure state of a DataTable is saved in a cookie so when page is reloaded it maintains the sort order of fields. This is my code, but bStateSave seems to be having no effect whatsoever.
I followed the method described here: http://datatables/examples/basic_init/state_save.html.
What am I doing wrong? Will appreciate help!
tbl = $(selector).dataTable({
"bStateSave": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": dataSource,
"iDeferLoading": totalRecCount,
"sDom": layout ? layout : defaultLayout,
"fnDrawCallback": drawCallback,
"aoColumns": aoColumns,
"oLanguage": {
"sSearch": ""
}
});
Share
Improve this question
edited Sep 24, 2013 at 4:09
madth3
7,34412 gold badges52 silver badges74 bronze badges
asked Nov 9, 2012 at 13:59
Ravish BhagdevRavish Bhagdev
9551 gold badge13 silver badges27 bronze badges
2
- Try removing as many of the other settings as you can, then re-add them one by one. – Blazemonger Commented Nov 9, 2012 at 14:05
- The cookie is named using the tableId + the URL. Can you use chrome dev tools > resources > cookies > to check what cookies are being created? – barry Commented Nov 9, 2012 at 16:06
1 Answer
Reset to default 5OK, I found the answer here: http://datatables/forums/discussion/ment/41588
In short it will not work when using iDeferLoading. Will have to maintain that state manually using a cookie which gets created and updated everytime the user sorts or store it elsewhere in the user model.