I want to remove some rows from datatable based on their respective indexes.The indexes are in form of an array. Upon clicking a button the function gets the array and finds each of them in the datatable then remove them .I have been able to create the code and its able to execute perfectly.Now the issue is not all the rows are removed,lets say we have 5 rows that we want to remove only 2 rows are removed.How can i remove all the rows in the table with all the respective indexes.This is my code
var productsIds=['2','3','4','5','6']
var productsTable=$('#productsTable').DataTable()
productsIds.forEach(function(id) {
var columnIndex = 0;
var rowIndex = productsTable.column(columnIndex).data().indexOf(id);
productsTable.row(rowIndex).remove();
});
productsTable.draw();