I've found some SO threads about reinitializing a datatable using the old API, but I think they're deprecated now.
I have an existing rendered datatable. I would like to refresh it with new settings. Using the new API, how would I do the following:
var dataTable = $('table.dataTable').DataTable();
var newDataTableSettings = {
data: { /* some data */ },
columns: { /* some columns*/ },
bFilter: false,
// etc...
};
// something like dataTable.clear().data(newDataTableSettings).draw()
My closest attempt:
dataTable.clear().draw()
dataTable.rows.add({ /* some data */ }).draw();
Use the
destroy
option :reinitialise with new data and removed search capabilities .
http://jsfiddle.net/3sonfsfm/
If you use an options literal you must reset it before reusing it :
This is because the
options
object is enriched with different values such asaaData
,aoColumns
an so on, which will conflict if you specify newdata
and newcolumns
.