Back to the index of articles and examples

Delete Rows By

Click on the checkboxes of the rows you want deleted and then click on the Delete Selected button. The rows will be deleted in one batch, avoiding individual calls to deleteRow, which implies multiple redraws of the table

I've defined a new method for DataTable deleteRowsBy which receives a single argument, a function which should return true or false depending on whether you want the record deleted or not. The function will receive an object which contains the values for each record as a simple object with the field names as its keys.

The method is used at the very bottom of the code section. On receiving the button click I call the deleteRowsBy method which simply returns the value Selected field.

The method is not complete. It does not check to see whether any of the records marked for deletion is on the array of selected rows or cells. It does not fire any event.

(2.5.1) If you drag the columns around, and then check a checkbox, it will fail, the getColumn function fails when columns have been moved around