active-table
active-table copied to clipboard
'cell-update' event seems to return wrong details
Hi @OvidijusParsiunas ,
When using the the 'cell-update' event listener:
- when the component is loaded, first n-1 rows have updateType: "Update", while the last one has updateType: "Add"
- when deleting any row, the rowIndex for updateType: "Removed" is always the last one.
While visually the last row of the table is always the one to be actually removed, the rowIndex should point to the original row in the data source, so in case we use "Sort Ascending"/"Sort Descending" we can still track the logical row that was deleted.
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/activeTable.bundle.js" type="module"></script>
</head>
<body>
<active-table id="at"
data='[
["Planet", "Diameter", "Mass", "Moons", "Density"],
["Earth", 12756, 5.97, 1, 5514],
["Mars", 6792, 0.642, 2, 3934],
["Jupiter", 142984, 1898, 79, 1326]]'
></active-table>
<script>
var tableElementRef = document.getElementById("at");
tableElementRef.addEventListener('cell-update', (cellUpdate) => {
console.log(cellUpdate.detail);
});
</script>
</body>
</html>