In my PHP application I used DataTable for table pagination, it works well. I want to apply the savestate(that is maintain the table pagination when refresh) for dynamically inserted rows(for static table savestate working fine). What i tried is.
Initialize the table
table = $('#child_table').DataTable({
"stateSave":true,
"bStateSave": true,
"ServerSide":true,
/*stateSaveCallback: function(settings,data) {
localStorage.setItem( 'DataTables_child_table', JSON.stringify(data) )
},
stateLoadCallback: function(settings) {
return JSON.parse( localStorage.getItem( 'DataTables_' + settings.sInstance ) )
}*/
});
If rows are empty from ajax call then clear the table.
if(dataTableArray.length < 1) {
table.clear();
table
one( 'preXhr', function ( e, settings, data ) {
data.clear = true;
} ).draw();
}
for(var i = 0;i < dataTableArray.length;i++){
table.row.add(dataTableArray[i]).draw();
}
Referred this one but not helpful.
Please help me to solve this problem.
Aucun commentaire:
Enregistrer un commentaire