Task: To delete records in db using ajax from a link in the table row, and maintain filters, sorting, pagination in the (awesome 🙂 DataTables jQuery plugin (link).
I would like the pagination to go to back if the last item on current page was successfully deleted, instead of showing the ‘No matching records found’ sort of message and a silly pagination info like ‘Showing 11 to 10 of 10 rows’
I’ll be taking from the step where you have your DataTables ready, with server-side data, filtering, pagination being done.
Steps:
iDisplayStart) for current page, and number of rows shown (iDisplayLength) currently. If their difference is >= 0, then we’ll use a small plugin to redraw the table (an ajax call), or a simple local delete of the row.Code:
The plugin you need is http://datatables.net/plug-ins/api#fnDisplayStart . Kindly do some research (instructions in link also) as to how to use plugins with DataTables if you are new to it:
References: