Datatables warning(table id = ‘example’): cannot reinitialise data table



DataTables warning (table id = ‘dataTable’): Cannot reinitialise DataTable. To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy

Try adding “bDestroy”: true to the options object literal, e.g.
Important to notice that even though this will fix the issue, it does not tackle the original problem, that is the unnecessarily duplicated initialization of Data tables.

Caution Destroy

The basis for altering the initialization parameters is that you need to destroy the old table and then create a new one with your new options. This has a very significant performance hit on the page, since a lot of calculations and DOM manipulation is involved, so if you can avoid this, and use the API, that is very strongly encouraged!


Alternative or Best practice

There are some ways that this error can crop up in code, so there also some methods that can be used to fix the issue, it is depending on precisely what you are trying to achieve.

Single initialisation

If we want to make use of multiple DataTables initialisation options, just apply them all together to the table. In the case of the code error above, where we try to disable paging and searching, the best practice is:

Datatables warning(table id = ‘example’): cannot reinitialise data table
5 (100%) 5 votes


Please enter your comment!
Please enter your name here