I have a filtered list as shown on the screenshot below
screenshot of the filtered list
I would like to calculate to total of "Km" in a separate field.
Can you help me ?
Here is the screen shot with the structure of the widget :
Something like the following will work:
TableListWidget.children._values
.map(function(obj){
return parseInt(obj.descendants.nameOfYourKMField.value);
})
.reduce(function(accumulator, currentValue){
return accumulator + currentValue;
});
TableListWidget.children._vaues
contains an array of all your table rows, the descendants
property of each row will contain the widget which has your KM value. We map the _values
array to an array of KM field values and then use the reduce
function to add them.