hot to fix Datatables warning: cannot reinitialize table id = file_table
hot to fix Datatables warning: cannot reinitialize table id = file_table
witdixx
Posts: 1Questions: 1Answers: 0
can somebody help me. when i run this code there is always a warning message cannot reinitialize datatables id = file_table
here is the code below:
function runDataTables2() {
table_file = $('#file_table').DataTable({
sDom: 'T<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"pull-right"ip>>>',
PaginationType: "bootstrap",
scrollX: true,
pageLength: 10,
custombutton: false,
retrieve: true,
order: [
[10, "desc"]
],
oLanguage: {
"sSearch": "",
"sLengthMenu": "_MENU_ "
},
tableTools: {
"sSwfPath": "<?php echo ASSETS_URL . TEMPLATE ?>/js/plugin/datatables/10/swf/copy_csv_xls_pdf.swf",
"aButtons": [{
"sExtends": "csv",
"sButtonText": "Export to CSV"
}]
},
initComplete: function() {
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var min = $('#parent_list').val();
if (min !== null) {
return true;
}
return false;
}
);
}
});
$("#parent_list").bind("change keyup", function(event) {
table_file.draw();
});
$('.dataTables_filter input').attr("placeholder", "Search");
$('.DTTT_container').css('display', 'none');
$('.DTTT').css('display', 'none');
// table_file.destroy();
}
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
Have you followed the troubleshooting steps at the technote link in the error?
https://datatables.net/manual/tech-notes/3
You have
retrieve: true,
which should just. return the API instance if the Datatable is initialized. There isn't anything obvious in your code. Make sure you aren't using$('#file_table').DataTable()
somewhere else in your code which might init Datatables. Please post a link to your page or a test case replicating the issue so we can help debug.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin