adds a custom data operation into Pivot Table

void addOperation(string name,function operation,object options);


namestringthe operation's name
operationfunctionthe function which will be called for each cell in the column with this operation
optionsobjectan 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});

Related samples


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.

See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix javascript component library and page of javascript pivot product.