Create and deleting multiple dataTable tables
Create and deleting multiple dataTable tables
I have a page that will need to have multiple dataTables all with different column headers.
So for example I have an accordion that has 5 "drop downs" which will result in 5 different tables in each section.
If I have them all named href="#accordion${$index}" (e.g "#accordion1", "#accordion2", ""#accordion3", etc) and then in each section I have id="table${$index}" (e.g. id="table1", id="table2" etc.) when the tables need to be destroyed and recreated (e.g. new accordion is created with 3 drop downs), is there a way to destroy/empty all of the old tables with a wildcard? (e.g. this.dataTable[0-4].destroy() and then $('#tableX').empty();
This question has an accepted answers - jump to answer
Answers
You can use jQuery selectors to select multiple tables (just comma separate them, like you do in CSS).
Or use the
$.fn.dataTable.tables()
method to get the existing DataTables in a single API instance.Allan