Reinitialize datatables
Reinitialize datatables
islamelshobokshy
Posts: 99Questions: 20Answers: 1
I have got
if ($.fn.DataTable.isDataTable("#achats_table")) {
$('#achats_table').DataTable().clear().destroy();
$('#achats_table').empty();
}
with destroy: true
but datatables doesn't want to get destroyed. The first time it's created, second time the number of rows double for a reason....
This discussion has been closed.
Replies
Your code seems to work here:
http://live.datatables.net/merufote/1/edit
Works with or without
destroy: true
.Maybe you can work up a test case showing the issue.
Kevin
Then try to recreate a datatable after it has been deleted. That doesn't work.
Are you recreating the HTML table after this:
$('#achats_table').empty();
If not then Datatables won't have a table to use.
Kevin
I do, of course recreate it. But it creates it next to my current one. So first time I had 5 columns/headers, next time I get 10. As if the clear/destroy doesn't work.
The basic example I provided works so there must be something more in your environment causing the issue. Can you provide a test case?
You can use one of the ajax based jsbin templates to build your ajax portion of the test case:
https://datatables.net/manual/tech-notes/9#Ajax
Kevin