Datatables warning (table id = 'ideas'): unable to reinitialize data table

I use data tables and add JS code parameters, the changes change, but I continue to receive a pop-up warning. How can I stop the warning?

$(document).ready(function() { $('#ideas').dataTable( { "aLengthMenu": [[5, 10, 15, -1], [5, 10, 50, "All"]] }); }); 

enter image description here

+6
source share
4 answers

If you just want to get rid of the warning window (for example, "stop the warning"), add this as the first line of your $(document).ready :

 $.fn.dataTableExt.sErrMode = 'throw'; 

Now, datatables data will throw an error visible as "uncaught error: Datatables warning ..." in the console instead of an ugly warning.

However, you have an error in your code / data, regardless of whether the error is now disabled.

The error "Warning DataTables (table id =" XXX "): the requested unknown parameter" XXX "from the data source for row X" occurs when there is a mismatch between the number of columns in the <table> column and the number of columns in the data column.

 <thead> <th>col A</th> <th>col B</th> </thead> 

Insert

 <tr> <td>test test</td> </tr> 

or

 <tr> <td colspan="2">test test</td> </tr> 

Reproduces exactly this error. So check your details again.

+7
source

You must use "bDestroy": true to populate the table during post back

+1
source

Did you dynamically populate the data? Then move your script after filling in the data.

Sort of,

 $(document).ready(function() { $('#example').dataTable( { "bProcessing": true, "sAjaxSource": "sources/arrays.txt", "aLengthMenu": [[5, 10, 15, -1], [5, 10, 50, "All"]] }); }); 
0
source

you must use "bDestroy": true .

Replace the DataTable that matches the specified selector, and replace it with those who have the properties of the passed new initialization object. If the table does not match the selector, then a new DataTable will be created as normal.

 $(document).ready(function() { $('#ideas').dataTable({ "aLengthMenu": [[5, 10, 15, -1], [5, 10, 50, "All"]], "bDestroy": true }); }); 

Also try this before creating a new data type that destroys previous data objects.

 $(document).ready(function() { $("#ideas").dataTable().fnDestroy(); $('#ideas').dataTable({ "aLengthMenu": [[5, 10, 15, -1], [5, 10, 50, "All"]] }); }); 
0
source

Source: https://habr.com/ru/post/947426/


All Articles