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

merlin2049ermerlin2049er Posts: 8Questions: 3Answers: 0

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

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017
    edited February 13

    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

  • merlin2049ermerlin2049er Posts: 8Questions: 3Answers: 0

    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

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017

    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

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017
    edited February 13

    Possibly you can use initComplete to perform the actions you are trying to do before. You can access the API with this.api() in initComplete.

    Please provide more details like your code so we can see the order of execution.

    Kevin

Sign In or Register to comment.