how to reinit DataTable - destroy doesn't work ?
how to reinit DataTable - destroy doesn't work ?
I have a table id #table.
when I upload my json file (there's no server side, only js code), according to filename I want to init DataTable from zero.
So the code is basically:
if (filename == 'a')
{
node.DataTable()...
}
else if (filename == 'b')
{
node.DataTable()... // completely different options than above using the same #table
}
Unfortunately, after I had success the first time, I'm unable to reload table with new data and I had some errors.
I used destroy: true, but it doesn't work.
What can I do to completely destroy any table reference ?
Answers
Ok, I solved with:
table.destroy();
$('#table').empty();
https://datatables.net/reference/api/destroy()
EDIT:
Btw, if I try to upload a wrong file and DataTable throw an error, I can't reload any file, even if correct :(