fnStateLoadCallback does not work in Datatables 1.8.2
fnStateLoadCallback does not work in Datatables 1.8.2
I am working on a large codebase and we are using the old Datatable 1.8.2. We will not be updating any time soon.
My issue is that I am trying to override the fnStateSaveCallback and fnStateLoadCallback methods to persist state to server-side. On my page I have x amount of tables. I create the datatable with similar options like so:
$(document).ready(function() {
$('#table').dataTable( {
.....
.....
"bStateSave": true,
"fnStateSaveCallback": function (oSettings, oData) {
console.log("inside save");
$.ajax({
"url": "/url",
"dataType": "json",
"data": oData
});
},
"fnStateLoadCallback": function (oSettings) {
console.log("inside load");
var o;
$.ajax({
"url": "/url",
"dataType": "json",
"success": function (json) {
o = json;
}
});
return o;
}
.....
.....
} );
} );
It appears that fnStateSaveCallback gets called and something is printed in the console. However, fnStateLoadCallback never gets called. The only time it gets called is if I remove the fnStateSaveCallback, if I put the load function back in it fails again.
I don't understand what I am missing here.
When does fnStateLoadCallback get called? Moreover, why on earth does fnStateLoadCallback get called when I remove fnStateSaveCallback?
Answers
Sounds odd. You won't be surprised to learn that 1.8.2 is no longer supported outside of enterprise support, however a couple of points:
falsy
value which stops the state loading.Allan
Hi Allan,
Much appreciated for the work you have done on Datatables in general. Certainly has helped thousands.
I decided to upgrade to version 1.9 instead and potentially 1.9.4.