4
votes

I want to use the aggregate value in another column (not the grouping column) in grouping header. For example, here is the demo from Kendo:

http://demos.telerik.com/kendo-ui/grid/aggregates

It aggregate the Units On Order for Units In Stock. I want to show the Average 14 in grouping header (besides Count: 5). Is it possible?

enter image description here

I tried to use template in header,

groupHeaderTemplate: "Units In Stock: #=value# (#=getAverage(data)# / #=count#)"

Then in getAverage(), I calculated the value based on data.

var aggregates = ds.aggregates();
var averaged = aggregates.UnitsOnOrder.average;

However, the average is the average of all rows, not the data within the group.

Any suggestions?

Thanks

1

1 Answers

7
votes

You can access the average in data.aggregates, which will contain the aggregates for the relevant group:

groupHeaderTemplate: "Units In Stock: #= value # (Count: #= count#)" +  
                     "(avg: #= aggregates.UnitsOnOrder.average #)"

(demo)