Change data in table but when i sort or search it use old data
Change data in table but when i sort or search it use old data
I use javascript to add data to html and then use DataTables to warp the table
$("#myTable tbody tr").remove();
... (use append string to add html code)
$("#myTable tbody").append(str);
if ( $.fn.dataTable.isDataTable( '#myTable' ) ) {
table = $('#myTable').DataTable();
}
else {
table = $('#myTable').DataTable( {
paging: true,
pageLength: 50,
lengthChange: false
} );
}
So when i call this method again to update data. The table changed the data but when I search or sort the data will come back to the first data.
How can I solve this problem?
Thank you