I second this request for a fix since if I have multiple tabs, each with a datatable and sorting settings and after working with the tables for a while, it will get 400 bad request error and the only thing to do is clear the cookies. I think there maybe a better way to encode the cookie string so it's more compact. Thanks
Sorry I overlooked the change to use localStorage in 1.9. For those who has issues with cookie limit, see this page: http://datatables.net/blog/localStorage_for_state_saving
Sorry about bumping this.
One could also set a larger cookie max size on the webserver. For instance we do
[code]LimitRequestFieldSize 16380[/code]
in Apache.
We've got it working with multiple tables and rather large filter sets (with server-side ColumnFilterWidgets !)
using some extra functions (thus leaving dt core untouched)
[code],"bStateSave":true
,"iCookieDuration": 60*60*24*365*5
,"fnStateSave": function (oSettings, oData) {
createFullCookie(\'save-'.$tablename.'\',JSON.stringify(oData));
}
,"fnStateLoad": function (oSettings) {
return JSON.parse(readFullCookie(\'save-'.$tablename.'\'));
}[/code]
... where the [code]\'save-'.$tablename.'\'[/code] part is of course our own php tablename var.
[code]function createFullCookie(name,value) {
var date = new Date();
date.setTime(date.getTime()+(24*60*60*1000*5000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}
function readFullCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}[/code]
I'd very strongly suggest using localStorage rather than cookies. DataTables 1.10 is making this change by default (cookies can optionally be used, in the same way that localStorage can optionally be used at the moment - you need to provide the code).
We have a button that clears all the cookies for the site.
If we could use a script that would remove this (and only this) localStorage data, that we can run from the site, I'd gladly use localStorage.
Is this possible ?
Replies
One could also set a larger cookie max size on the webserver. For instance we do
[code]LimitRequestFieldSize 16380[/code]
in Apache.
We've got it working with multiple tables and rather large filter sets (with server-side ColumnFilterWidgets !)
using some extra functions (thus leaving dt core untouched)
[code],"bStateSave":true
,"iCookieDuration": 60*60*24*365*5
,"fnStateSave": function (oSettings, oData) {
createFullCookie(\'save-'.$tablename.'\',JSON.stringify(oData));
}
,"fnStateLoad": function (oSettings) {
return JSON.parse(readFullCookie(\'save-'.$tablename.'\'));
}[/code]
... where the [code]\'save-'.$tablename.'\'[/code] part is of course our own php tablename var.
[code]function createFullCookie(name,value) {
var date = new Date();
date.setTime(date.getTime()+(24*60*60*1000*5000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}
function readFullCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}[/code]
http://datatables.net/blog/localStorage_for_state_saving
Allan
If we could use a script that would remove this (and only this) localStorage data, that we can run from the site, I'd gladly use localStorage.
Is this possible ?