I've got a strange issue with DataTables and destroy. I am using version 1.10.3 (but also tried 1.10.7) and fixedColumns Plugin (3.0). When I want to destroy the table I get an error in the plugin:
Uncaught TypeError: $(...).fn is not a function
My init looks like this:
fulltable = $('#auditplan_table_fs').dataTable();
and the destroy
fulltable.fnDestroy();
but I've also tried to initalize via .DataTable()
and destroy via .api().destroy()
or .destroy()
which leads to the same result. Any possible solution would be appreciated.
UPDATE:
As it seems it isn't a problem with FixedColumns, here is some more information. I'm calling the dataTable in an ajax success
like this:
$('#auditplan_table_fs').append(responseData.findinglist.html);
fulltable = $('#auditplan_table_fs').dataTable({
scrollY: newheight,
scrollX: true,
scrollCollapse: true,
"bSort": false,
paging: false
});
new $.fn.dataTable.FixedColumns(fulltable);
In a document change function (when I select some values from a dropdown) I try to destroy the table like I posted before and then call the ajax function again.
The fulltable
variable is defined in my document ready, the assignment happens, as already told, in my success
function. When I print out the variable right before the destroy, everything seems to be fine.
UPDATE: It seems to be a bug in fixedColumns itself. I found out I am using 3.0.0 and the newest version is 3.0.4. With this one, I passed the first error and come up with a new one. I now get stuck in Line 1107:
Uncaught TypeError: Cannot read property 'anCells' of undefined
I suppose it has to do something with my init in an ajax call.
LAST UPDATE: Ok, I was to fast. It was only a caching problem. With the new version, everything is working fine.