ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mikep on August 29, 2020, 02:52:13 am
-
Hi. I have a grid that displays a variable number of columns w/costs. What's the best way to have a column at the end of the grid that sums these columns?
In this example I have two columns that I need to sum, but it could be any number of columns
https://jsfiddle.net/cvbwstL2/
-
you may add a property includeInSum: true to those columns and then use a formula to sum the columns.
formulas: [
['sum', function(rd){
var val = 0;
this.getColModel().forEach(function(column){
if(column.includeInSum){
val += rd[ column.dataIndx ] * 1;
}
})
return val;
}]
],
https://jsfiddle.net/eafr126d/
-
Thank you. Is there a way to apply that at the group level?
https://jsfiddle.net/qpu7fdLj/
-
Formula doesn't work for group title rows.
However end result can be achieved in some cases ( such as yours ) by adding summary: {type: 'sum'} to last column also.
https://jsfiddle.net/stgbvnpr/
-
That worked. Thank You!