Thank you for this, however your documentation omits to mention the third parameter "data", which is all the data in the grid.
The solution for others:
pq.aggregate["margin"] = function(arr, col, data){
var profit=0,
revenue=0;
$.each(data, function(i,v){
profit += floatval(v["profit"]);
revenue += floatval(v["revenue"]);
});
return profit / revenue;
};
Then in the grid options:
groupModel: {
on: true,
header: false,
grandSummary: true,
agg: {
revenue: "sum",
approved_cost: "sum",
unapproved_cost: "sum",
estimated_cost: "sum",
profit: "sum",
margin: "margin"
}
},
summaryTitle:{ sum: "{0}", margin:"{0}" },