Get DataTables to work with rows added dynamically?
Get DataTables to work with rows added dynamically?
whaler
Posts: 1Questions: 1Answers: 0
I have a table that I can add rows and columns to using jQuery. However, when I add a new row, this doesn't get updated with DataTables and the row is removed once I sort any of the columns or perform any DataTables action. I can provide the code, but it's basically just adding a "<tr><td> </td>... etc </tr>" to the table after the last row.
Any suggestions?
This discussion has been closed.
Answers
Hi @whaler ,
Once you've initialised the table, if you add a row to the DOM, DataTables won't be aware of it by default. There's two things you can do:
row().add()
rows().invalidate()
to re-read the DOMCheers,
Colin