fnDestroy all Data Tables on page??
fnDestroy all Data Tables on page??
JimKnoll
Posts: 10Questions: 3Answers: 0
// This works for me
function unDataTableize() {
$("#DataTables_Table_0").dataTable().fnDestroy();
...
}
// I wanted to do it like below so I could convert the 0 into i using a for (var i = 0; i < tbls.length; i++)
// but I can not even get it to work for the first table index 0
function unDataTableize() {
var tbls = $('Table');
tbls[0].dataTable().fnDestroy();
}
//Can anyone point me to my mistake?
This discussion has been closed.
Answers
tbls[0]
gives you the DOM node, not a jQuery object, so there is nodataTable()
method.In 1.10 you could simply use
$('table.dataTable').DataTable().destroy();
with no need for any loops.Allan
perfect thanks
wait did you mean
$('table.dataTable').dataTable().fnDestroy();
not see cap
$('table.dataTable').DataTable().destroy();
While that works... it only seems to work on the first table defined on the page. not on subsequent tables.
I am at 1.9.1 so I think I am good with that.
function unDataTableize() {
var tbls = $('table.dataTable');
for (var i = 0; i < tbls.length; i++) {
tbls.eq(i).dataTable().fnDestroy();
}
}
Nope - meant what I typed :-). Here is an example showing it working: http://live.datatables.net/sabesuju/1/edit .
Okay - the new API will not work. As I noted, in my comment above the code I suggested was for 1.10.
Allan