Cannot reinitialise DataTable on second search

Cannot reinitialise DataTable on second search

mattheanmatthean Posts: 10Questions: 3Answers: 0

I create the table and the initial search works. However, if I do a second search, I get the error 'Cannot reinitialise DataTable.' I looked at the documentation for how to fix it, but it(destroy, etc) removes things like pagination. How do I modify the code so I can do repeated searches?

var table = $('#dtable').DataTable({
                    order: [[3, 'asc']],
                });

                table.clear().draw();

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,996Questions: 87Answers: 421
    Answer ✓

    You have to make sure your data table initialization code does not get executed again when you repeat the search. Just post a test case please as per the forum rules.

    If you can't avoid running the code again you could use this option:
    https://datatables.net/reference/option/retrieve

  • mattheanmatthean Posts: 10Questions: 3Answers: 0

    For the sake of simplicity, the retrieve works for what I want.

Sign In or Register to comment.