Footer with multiple entries
With the latest unstable version, can I have multiple entries for my Footer? Eg., I want my footer to have "Total" and "Average" for each column. So, Total and Average will be displayed under each column in the footer in separate rows.
Define functions
Array.prototype.avg = function (e) {
if (this.length == 0)return 0;
var t = 0;
for (var n = 0; n < this.length; n++) {
t += this[n]["entity"][e] / this.length
}
return t
};
Array.prototype.total = function (e) {
if (this.length == 0)return 0;
var t = 0;
for (var n = 0; n < this.length; n++) {
t += this[n]["entity"][e]
}
return t
};
Inside the controller define function for aggregating average and total:
averageAndTotal = function (e, t) {
var n = e.avg(t.field);
var r = e.total(t.field, n);
return [n, r]
};
Create a template
var temp = '<div class="ui-grid-cell-contents" col-index="renderIndex"><div>avg: {{ col.getAggregationValue()[0] | number : 2}}<br>total: {{ col.getAggregationValue()[1] | number : 2}}</div></div>';
Set aggregationType to averageAndTotal and footerCellTemplate to temp in gridOptions for column that you want to have this footer.
Hope it will help. Good luck!
Solution provided (not clear to me if that will work), but no response for 3 weeks. Assuming issue is resolved, closing.
It worked. Great solution! @cyberlake
great