Updating rows in a page on row delete
Updating rows in a page on row delete
I have a table with many records loaded via ajax.
The paging is allowed.
When a row is deleted, the number of rows in the page is not updated, so if I delete all the row in the current page, it remains showed an empty page, even if is not the last page of the table.
For example if I'm on page 1 of 10 in my datatable and I delete a record, I would like that the page is updated with next record for the second page, to continue have 10 records in the page.
Is there a way to achieve this without redraw the entire datatable?
Thanks
This question has an accepted answers - jump to answer
Answers
Are you using server-side processing (
serverSide
)? If you are, then yes, you would need to calldraw()
to get the latest draw information from the server.If you aren't using server-side processing, then the display should be updated to show the next record as soon as you call
draw()
after therow().remove()
.Here is a little example of that, which will remove the first row of the table, for the page that you are currently on: https://live.datatables.net/gehehedu/1/edit .
Allan
Thanks Allan.
That works.
I was not calling draw() correctly.