From e238fb287a1cb0949849ee503eb2285d79fa5411 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Fri, 29 Apr 2022 13:27:46 +0200 Subject: [PATCH] Fix remove rows using library API --- ereuse_devicehub/static/js/main_inventory.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index ccb34a05..f7f2531b 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -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) - 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)) { - row.remove() + rowsToRemove.push(i) } - }) + } + table.rows().remove(rowsToRemove); } }