Reputation: 61
I have used row.remove(); but if am on 3rd page and delete a row form 3rd page it shows again when goes to 2nd and comes back to 3rd page.
row = $(deleteParent).closest("tr").get(0); $(row).remove();
I have deleted that row from backend (database) through ajax but why it seems in the datatable if i refresh datatable then that row is removed permanently.
i have also tried
var aaa = oTable.DataTable(); aaa.row(row).remove().draw();
but it redirect me to the first page of the datatable can any body tell me how to prevent going to first page.
Upvotes: 0
Views: 267
Reputation: 5699
You're very nearly there, just need to pass false
to the draw()
function like this:
$('#example').on("click", "button", function(){
table.row($(this).parents('tr')).remove().draw(false);
});
Working JSFiddle: https://jsfiddle.net/annoyingmouse/7c0v1ra3/
Please make sure you only delete the row in the front-end when you know for certain it's deleted from the back-end :-)
Upvotes: 1