Cannot read property 'style' of undefined after reloading the table
Cannot read property 'style' of undefined after reloading the table
Hi guys !
I'm learning how to use this amazing plugin but I'm having some problem to reload the data and inject it into datatable.
I have a <select > box and a Button. Everytime I press the button, I bring the data from selected table. So I need to reload the content of the datatable everytime I click the button and choose a new/same table, right ?
This is how i'm handling it right now:
$('#btnTeste').on('click', function(e){
if ( $.fn.DataTable.isDataTable('#myTable') ) {
$('#myTable').DataTable().destroy();
}
});
But sometimes while I'm getting picking new tables, I get the error:
Cannot read property 'style' of undefined after reloading the table
Then if I try to use the search
feature. The data inside the table get all messed up.
Any idea how to fix it?
This is how I'm feeding the table:
$('#myTable').DataTable({
"aoColumns" : columns,
"aaData": resultado
});
where both columns
and resultado
are data objects retrieved as a Json file through Ajax call.