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))
Danio
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.
This discussion has been closed.
Answers
To add new rows to the table, you need to use the API - such as
row.add()
orrows.add()
.See also the FAQs.
Allan
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