row().remove()

Since: DataTables 1.10

Delete the selected row from the DataTable.

Description

This method (and its plural counterpart, rows().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. This method can called simply as a chained method of the rows().remove() method's returned object - for example table.rows().remove().draw();. This method is used to reduce the number of draws required if multiple rows are being deleted for optimisation.

Type

function row().remove()

Description:

Delete the selected row.

Returns:

tr row node.

Examples

Delete a row when a delete icon is clicked upon in the row:

var table = $('#example').DataTable();

$('#example tbody').on( 'click', 'img.icon-delete', function () {
	table
		.row( $(this).parents('tr') )
		.remove()
		.draw();
} );

Transfer a row from one table to another (note that this is for DOM sourced tables, use row().data() for other data sources):

var table1 = $('#example1').DataTable();
var table2 = $('#example2').DataTable();

$('#example tbody').on( 'click', 'img.icon-transfer', function () {
	var row = table1.row( $(this).parents('tr') );
	var rowNode = row.node();
	row.remove();

	table2
		.row.add( rowNode )
		.draw();
} );

Related

The following options are directly related and may also be useful in your application development.