How to refresh datatable after adding new TR's to table.(HTML (DOM))

How to refresh datatable after adding new TR's to table.(HTML (DOM))

DanioDanio Posts: 2Questions: 1Answers: 0

Hi everyone!

Quick question, I am using javascript to add new rows(TRs) to a datatable. When I try and use datatables functionality like Sorting, the rows disappear so it seems like I have to re-initialize or refresh DataTables. Anyone know how to do so?

Adding rows like this : $('#dtQueryResults>tbody').html(html);

Thank you for your help.

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    To add new rows to the table, you need to use the API - such as row.add() or rows.add().

    See also the FAQs.

    Allan

  • DanioDanio Posts: 2Questions: 1Answers: 0
    edited January 2015

    What I did, was when I refresh the data(by adding a whole new set of TRs to the table), I destroyed DataTables then recreated it

This discussion has been closed.