remove()
Remove (delete) entries from the table.
Please note - this property requires the Editor extension for DataTables.
Description
This method is used to remove one or more records from a DataTable. The main editing form is not shown in the remove display (as it has no relevance here, unlike in the create and edit displays), so this method is typically used in conjunction with the message() method to ask the user to confirm they want to delete the selected records.
This method has two different styles of being called. Editor will automatically detect which method is used and act accordingly. Although the newer style introduced in Editor 1.3 is preferred for its flexibility, the older style is still retained for backwards compatibility and can continue to be used.
Types
remove( items [, show ] [, options ] )
Remove (delete) entries from the table.
This new form of the remove() method was introduced in Editor 1.3 to take advantage of the the updated chaining interface and form configuration options.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | items | No | |
Row selector for the record(s) to be removed. | |||
| 2 | show | Yes - default:true | |
Immediately show the form ( | |||
| 3 | options | Yes | |
Form configuration options, including the ability to set the title, buttons and behaviour of the form. See also | |||
Returns:
DataTable.Editor: Editor instance
remove( items [, title [, buttons [, show ]]] )
Remove (delete) entries from the table.
This older form of the remove() method is retained in Editor 1.3 for full backwards compatibility, but the new form, documented above, is preferred.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | items | No | |
Row selector for the record(s) to be removed. | |||
| 2 | title | Yes | |
Form title to display. See | |||
| 3 | buttons | Yes | |
Buttons to show in the form. See | |||
| 4 | show | Yes - default:true | |
Immediately show the form ( | |||
Returns:
DataTable.Editor: Editor instance
Examples
Delete a row with a message to let the user know exactly what is happening:
$('#myTable tbody').on('click', 'a.delete-row', function () {
editor
.title('Delete row')
.buttons('Confirm delete')
.message('Are you sure you want to remove this row?')
.remove(this);
});Delete the selected row without asking the user for confirmation:
$('#myTable tbody').on('click', 'a.delete-row', function () {
editor.remove(this, false).submit();
});Delete all rows in a table with a submit button:
editor
.title('Delete all rows')
.buttons('Confirm delete')
.message('Are you sure you want to delete all rows?')
.remove('tr'); // select all rowsRelated
The following options are directly related and may also be useful in your application development.