Skip to content

Instantly share code, notes, and snippets.

@jgraglia
Created August 5, 2014 07:43
Show Gist options
  • Save jgraglia/63a0ba6b8cbfce2e4ce0 to your computer and use it in GitHub Desktop.
Save jgraglia/63a0ba6b8cbfce2e4ce0 to your computer and use it in GitHub Desktop.
Datatables : save state in html5 local storage
datatable = $('#table').dataTable( {
"bStateSave": true,
// là suite est optionnelle. par défaut cookie, là on utilise localstorage html5
"fnStateSave": function(oSettings, oData) {
localStorage.setItem('DataTables_' + this.fnSettings().sTableId, JSON.stringify(oData));
},
"fnStateLoad": function (oSettings) {
return JSON.parse(localStorage.getItem('DataTables_' + this.fnSettings().sTableId));
}
....
});
// voir http://legacy.datatables.net/ref#bStateSave
// voir http://legacy.datatables.net/ref#fnStateSave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment