I have a column with buttons in a table I'm using jQuery datatable plugin. The buttons say "Remove" and the idea is that when you click on that button it deletes the current row in the table.
When I call fnDeleteRow
it seems to work the first time but no any further time for that row so it looks like its not really deleting the row properly.
remove() ) will remove the selected row from the DataTable completely, deleting the allocated memory for data and node from the browser. Please be aware that this method removes the data from the table internally but that action won't be visually shown until the draw() method is called to update the display.
Using the closest() method we select the current row ie closest tr of our delete button, and then with the remove() method will delete that record. Similarly for deleting the next row tr we use . next() method along with . remove() this will delete the next table row.
workRow. Delete(); If a row is marked for deletion and you call the AcceptChanges method of the DataTable object, the row is removed from the DataTable.
Try this:
var row = $(this).closest("tr").get(0); oTable.fnDeleteRow(oTable.fnGetPosition(row));
If it doesn't work, check the following example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With