bug: Save and go back to list
- Single Page
Posted 21 September 2012 - 11:10 AM
First of all, thank you for GC, it's really cool!
I found a strange bug with the "Save and go back to list".
Using it after 6x times I get error message:
[b] Bad Request[/b]
[color=#000000][font=Times New Roman][size=1]Your browser sent a request that this server could not understand.[/size][/font][/color]
[color=#000000][font=Times New Roman][size=1]Size of a request header field exceeds server limit.[/size][/font][/color]
[attachment=294:bug_save_and_back_to_list.JPG]
The bug is not on the "Save" button, but sometimes I need to hide it.
It seems that, the bug is only in the datatables theme.
[color=#282828][font=helvetica, arial, sans-serif]Thanks in advance![/font][/color]
Posted 21 September 2012 - 12:10 PM
DataTables keeps the settings of each table in storage with either cookies or local storage.
This becomes a problem because it works by default by looking at the current URL for the cookie name.
Because GroceryCrud uses urls like sometable/success/3, sometable/success/2, the amount of data becomes too big (over 4kB) at some point.
Some solutions:
1. Disable state saving altogether:
http://datatables.net/usage/features#bStateSave
2. Use Datatables' localStorage, which has no limit on the amount of data
http://datatables.net/blog/localStorage_for_state_saving
3. Check if the url includes /success/(number) and don't save data for that url
OR: figure out what the original url is and use that
This is how I did myself: (datatables.js)
// http://mathiasbynens.be/notes/localstorage-pattern
function localstorage_supported()
{
var storage,
fail,
uid,
supported;
try {
uid = new Date;
(storage = window.localStorage).setItem(uid, uid);
fail = storage.getItem(uid) != uid;
storage.removeItem(uid);
fail && (storage = false);
} catch(e) {}
supported = false;
if(storage) supported = true;
return supported;
}
$(document).ready(function() {
var use_storage = localstorage_supported();
var pathname = window.location.pathname;
if(if(pathname.indexOf("/success/") != -1) use_storage = false;
}
// ...
oTable = $('#groceryCrudTable').dataTable({
// ...
// specify if using state saving
"bStateSave": use_storage,
// using local storage for state saving
"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname) );
},
// ...
});
Posted 21 September 2012 - 12:20 PM
Posted 21 September 2012 - 12:57 PM
Posted 23 September 2012 - 19:59 PM
Posted 23 September 2012 - 20:03 PM
I hate this comment system.. I cannot paste code with tabs in it... also, if I try to edit the post again the code loses all tabs and leading spaces.. how annoying is that!
[/quote]
I just checked it and you are right. I will report it to the forum developers or I will search for a quick fix for that. I think this happens after the update of the forum.
Thanks to mention that.