mluna
December 4, 2023, 7:39pm
1
Is there any way to limit the maximum value of a cell inside a table (by matching it to the next cell's value/or any other way)?
The idea is not to exceed the request of an available quantity. The max value of all rows would be different according to what's available.
Skizhu
December 5, 2023, 2:54am
2
you will need to have a variable or transformer to store the qty of each row, get the sum and subtract it to the available qty
e.g.
Sum of rows
{{ table1.data.reduce((accumulator, currentObject) => {
if (currentObject.hasOwnProperty('qty')) {
return accumulator + currentObject.qty;
}
return accumulator;
}, 0)
}}
the major issue with this approach is that you will need to save every change made to the qty row before editing another row because the variable/transformer will not keep track of edited cells without saving
If you want it to update in real-time while editing, you need to merge the .changesetArray()
mluna
December 5, 2023, 8:02pm
3
Thank you for your answer. I'm trying to match the max value of a cell in a row to another's in the same row.
In example:
Buy max limit = available.
mluna
December 8, 2023, 9:18pm
4
Ended up doing it like this and it worked fine.
It would be nice if the documentation said that you can use i as an index inside that property.