Fix remove rows using library API

This commit is contained in:
RubenPX 2022-04-29 13:27:46 +02:00
parent 0fd12ee37c
commit e238fb287a
1 changed files with 7 additions and 3 deletions

View File

@ -326,11 +326,15 @@ async function processSelectedDevices() {
const newTable = Array.from(tmpDiv.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value) const newTable = Array.from(tmpDiv.querySelectorAll("table.table > tbody > tr .deviceSelect")).map(x => x.attributes["data-device-dhid"].value)
table.rows().dt.activeRows.forEach(row => { // https://github.com/fiduswriter/Simple-DataTables/wiki/rows()#removeselect-arraynumber
const rowsToRemove = []
for (let i = 0; i < table.activeRows.length; i++) {
const row = table.activeRows[i];
if (!newTable.includes(row.querySelector("input").attributes["data-device-dhid"].value)) { if (!newTable.includes(row.querySelector("input").attributes["data-device-dhid"].value)) {
row.remove() rowsToRemove.push(i)
} }
}) }
table.rows().remove(rowsToRemove);
} }
} }