Table headings repeat after destroying and redrawing DataTable

Table headings repeat after destroying and redrawing DataTable

sjw01sjw01 Posts: 67Questions: 36Answers: 1
edited June 2021 in Free community support

Test Case: http://live.datatables.net/zigijote/1/

I have a DataTable which accesses a JavaScript array to display data - works fine.

I have added a filter on the page (see top left: All Sale Types) which uses Ajax to go back to the server (not included in demo), gets filtered data and then redraws the DataTable.

Problem: When I do this and redraw the table, it duplicates the row headings into the second row.

You'll notice on original draw - it appears as expected
BUT - when you redraw, it adds extra headings into second row.

How do I stop this?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    It looks like you need to remove the header rows explicitly as they were added outside of DataTables's control. You can do that with:

      $('table tr').remove();
    

    See updated example here: http://live.datatables.net/zigijote/2/edit

    Colin

Sign In or Register to comment.