Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete current row with jquery datatable plugin

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.

like image 231
leora Avatar asked Dec 18 '09 03:12

leora


People also ask

How to remove the row from DataTable?

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.

How do you delete a current row?

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.

How to delete a row in DataTable in asp net?

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.


1 Answers

Try this:

var row = $(this).closest("tr").get(0); oTable.fnDeleteRow(oTable.fnGetPosition(row)); 

If it doesn't work, check the following example

like image 139
Jason Orendorff Avatar answered Oct 14 '22 19:10

Jason Orendorff