How to delete a row without reference to the DOM node
How to delete a row without reference to the DOM node
alawson107
Posts: 3Questions: 1Answers: 1
My app receives a websocket instruction from the server to delete a specific row. The row may or may not be in the DOM but it does appear in the data() array. How can I delete it using javascript? The row().remove() command seems to need a DOM node and the data().splice(index, 1) function does not seem to delete anything.
This discussion has been closed.
Answers
The
row()
method can select rows using a number of different methods via therow-selector
method.Do you have the id of the row to be deleted, or some other data point in it? You can use that with the row selector to remove it.
Regards,
Allan
I didn't realize that the row() method could take an index directly, ie. row(index), to select the row. It worked perfectly. Thanks!
I should just point out that as an integer, the row selector is selecting based on the row data index! That index is internal to DataTables, and it can chance if some rows preceding it are deleted. Only the indexes given by DataTables should really be used -
row().index()
.Allan