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 curr
This is how it works for me. In document ready function I assign converted version of HTML table to a variable and when a button in the is clicked I go through parents/childs with JQuery and send the row you get as a parameter to the library's fnDeleteRow() function.
Here's is the comments from the library function. And an example that's mentioned in library.
/**
* Remove a row for the table
* @param {mixed} target The index of the row from aoData to be deleted, or
* the TR element you want to delete
* @param {function|null} [callBack] Callback function
* @param {bool} [redraw=true] Redraw the table or not
* @returns {array} The row that was deleted
* @dtopt API
* @deprecated Since v1.10
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable();
*
* // Immediately remove the first row
* oTable.fnDeleteRow( 0 );
* } );
*/
// And here's how it worked for me.
var oTable;
$("document").ready(function () {
oTable = $("#myTable").dataTable();
});
//Remove/Delete button's click.
$("a[name='deleteColumn']").click(function () {
var $row = $(this).parent().parent();
oTable.fnDeleteRow($row);
});