adds a custom data operation into Pivot Table
name | string | the operation's name |
operation | function | the function which will be called for each cell in the column with this operation |
options | object | an object with operation options: leavesOnly or ids properties (see details) |
grida.addOperation("avr", function(data) {
var sum = 0;
for (var i = 0; i < data.length; i++) {
if( data[i] )
sum += window.parseFloat(data[i], 10);
}
return data.length?(sum/data.length):0;
}, {leavesOnly: true});
The operation parameter takes an array with the values of child cells.
The leavesOnly option takes a boolean value. If set to true, the operation function will take only values of leaves child rows (rows that do not have sub-rows).
The ids option takes a boolean value. If the property is set to true, the operation function will take ids of ungrouped data items as the 4th parameter.
This method is applied to the Pivot Table only. For the Pivot Chart, use the addGroupMethod() method.