Questions on: bStateSave
Questions on: bStateSave
BillyThaKid
Posts: 2Questions: 0Answers: 0
Hey Allan,
Thanks for the extraordinarily useful plugin!!
So here's my scenario - I have a datatable with properties set to true for bServerSide, bStateSave, and bPaginate. I'm returning records using sAjaxSource (via jSon data). Each of the results links off to a news story on a separate page. Everything is pretty much working as expected, however, I'm wondering if anything can be done regarding the following -
After running a search for something, clicking on a result, and clicking the back button, my sAjaxSource method gets hit again - resulting in the 'Processing' text to come up again. You'd think that the method wouldn't be hit again and that the Ajax results would still be loaded from the first hit. I also noticed that this only seems to happen with Internet Explorer & Chrome. Firefox doesn't seem to have this issue (the method doesn't get hit after hitting the back button). Here's the code I'm using -
[code]
var oTable = $('#dTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"bStateSave": true,
"fnStateSave": function (oSettings, oData) { save_dt_view(oSettings, oData); },
"fnStateLoad": function (oSettings) { return load_dt_view(oSettings); },
"bPaginate": true,
"bAutoWidth": false,
"sAjaxSource": "/Json/Results",
"bLengthChange": true,
"bFilter": true,
"iDisplayLength": 10,
"aLengthMenu": [[10, 20, 30, 50], [10, 20, 30, 50]],
"sPaginationType": "full_numbers",
"oLanguage": {
"sSearch": "Search:"
},
"sDom": '<"top"lf<"clear">>rt<"bottom"ip<"clear">>',
"fnDrawCallback": function () {
var filterId = document.getElementById('input_filter');
var filterChildNode = filterId.firstChild.childNodes[1].value;
$("#dTable").removeHighlight().highlight(filterChildNode);
},
"aaSorting": [[0, "desc"]]
});
[/code]
Any advice would be appreciated!
Thanks!!
Matt
Thanks for the extraordinarily useful plugin!!
So here's my scenario - I have a datatable with properties set to true for bServerSide, bStateSave, and bPaginate. I'm returning records using sAjaxSource (via jSon data). Each of the results links off to a news story on a separate page. Everything is pretty much working as expected, however, I'm wondering if anything can be done regarding the following -
After running a search for something, clicking on a result, and clicking the back button, my sAjaxSource method gets hit again - resulting in the 'Processing' text to come up again. You'd think that the method wouldn't be hit again and that the Ajax results would still be loaded from the first hit. I also noticed that this only seems to happen with Internet Explorer & Chrome. Firefox doesn't seem to have this issue (the method doesn't get hit after hitting the back button). Here's the code I'm using -
[code]
var oTable = $('#dTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"bStateSave": true,
"fnStateSave": function (oSettings, oData) { save_dt_view(oSettings, oData); },
"fnStateLoad": function (oSettings) { return load_dt_view(oSettings); },
"bPaginate": true,
"bAutoWidth": false,
"sAjaxSource": "/Json/Results",
"bLengthChange": true,
"bFilter": true,
"iDisplayLength": 10,
"aLengthMenu": [[10, 20, 30, 50], [10, 20, 30, 50]],
"sPaginationType": "full_numbers",
"oLanguage": {
"sSearch": "Search:"
},
"sDom": '<"top"lf<"clear">>rt<"bottom"ip<"clear">>',
"fnDrawCallback": function () {
var filterId = document.getElementById('input_filter');
var filterChildNode = filterId.firstChild.childNodes[1].value;
$("#dTable").removeHighlight().highlight(filterChildNode);
},
"aaSorting": [[0, "desc"]]
});
[/code]
Any advice would be appreciated!
Thanks!!
Matt
This discussion has been closed.
Replies
DataTables sets the jQuery anti-cache parameter by default, so that might well be what is causing the problem. You can either override using fnServerData or just after that one line in DataTables.
DataTables 1.10 will make it possible to do:
[code]
$('#dTable').dataTable( {
ajax: {
url: '/Json/Results',
cache: true
},
...
} );
[/code]
That's already in Git if you want to try it.
Allan
Thanks again for your help!!
Matt