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, which is the unnecessarily duplicated initialization of Data tables.
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. Destroy 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.
If we want to make use of multiple DataTables initialization options, 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: