Search and Sorting doesn't work with newly created/deleted rows
Search and Sorting doesn't work with newly created/deleted rows

I'm not using the Editor extension. Rather, I create and remove rows with jquery. However, once i remove or create a row, the sorting/search function doesn't recognize the new row and once you try to search or sort, the new rows are no longer visible in the datatable and the deleted rows are shown again.
What needs to be done to make the sorting/search recognize that a new row is part of the datatable or has been removed?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Sounds like you are not using the Datatable's APIs to update the data. You can use APIs like:
rows.add()
orrow.add()
to add rows.row().data()
orcell().data()
to update datarow().remove()
orrows().remove()
to remove a row or multiple rows.If you use something other than Datatables APIs to change the table data then Datatables won't know about the changes which results in searching and sorting to not work as expected. In this case you can use one of the
invalidate()
methods likerows().invalidate()
orcell().invalidate()
. This will tell Datatables to update its data cache with the current data.Kevin
kthorngren, thanks for the response. Sounds like i do need to take a look at the API then and create the new rows that way. Thank you.