Statesas does not work with datatables when rows are added dynamically
I am using DataTables and I am initializing the table with
$(document).ready(function() {
$('#example').dataTable( {
stateSave: true
} );
} );
I am dynamically populating a table using $ ('# example'). row.add (...)
When I reload or revise my page, the table is empty again. Should StateSave work with dynamically inserted row?
+3
user3871397
source
to share
3 answers
State persistence is not used to persist data - only pagination, etc.
+1
Webezine
source
to share
Try changing stateSave to bStateSave. Worked for me when my code had this same problem.
Thus, the code will look something like this:
$(document).ready(function() {
$('#example').dataTable( {
bStateSave: true
} );
} );
+1
MrMadsen
source
to share
Make sure you have local storage enabled! Found this myself and it was not enabled which caused the problem.
0
user7219680
source
to share