I've got a rails partial that renders a datatable with search fields
I've got a rails partial that renders a datatable with search fields

But I need to initialize the table with several parameters before hand.
I get ...
DataTables warning: table id=datatable - Cannot reinitialise DataTable.
not sure how to combine these two things working together.
Answers
Have you tried the troubleshooting steps at the link in the error?
https://datatables.net/manual/tech-notes/3
Without seeing your code its hard to say what the issue is but my guess is you are trying to get an instance of the API, ie
var table = $( selector ).DataTable();
before initializing with the options. This won't work and the code will need to be refactored to rearrange the order of operations.Or you are trying to initialize Datatables with one set of options then again with another set of options. In this case combine the two. The technote discusses these options.
If you still need help then please post your JS code so we can see what you are tying to do. Better is a link to a test case replicating the issue so we can follow the code flow.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
yes, we have a rails partial that just displays the datatable with search fields on top, but trying to get something done before that causes an error
I’m not sure either without seeing what you are trying to do. I don’t know what you are trying to do before to offer suggestions.
Kevin
Possibly you can use
initComplete
to perform the actions you are trying to do before. You can access the API withthis.api()
ininitComplete
.Please provide more details like your code so we can see the order of execution.
Kevin