I've created a Kendo grid that groups on 2 fields. So it groups on one field, and then further subgroups within the groups on a second field. I need to show sums for a third field for each group and subgroup.
The sums for the subgroups appear ok.
But the sums for the groups are wrong - they show the sum for all records instead of the sum per group.
This can be reproduced by pasting the code below in one of the demo areas in
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "company", groupHeaderTemplate: "#= value #" },
{ field: "department", groupHeaderTemplate: "#= value #" },
{ field: "headcount", groupFooterTemplate: "#= sum #", footerTemplate: "#= sum #" }
],
dataSource: {
data: [
{ company: "IBM", department: "Software", headcount: 4000 },
{ company: "IBM", department: "Software", headcount: 5000 },
{ company: "Apple", department: "Hardware", headcount: 2000 },
{ company: "IBM", department: "Hardware", headcount: 7000 },
{ company: "Apple", department: "Software", headcount: 6000 }
],
aggregate: [
{ field: "headcount", aggregate: "sum" }
],
group: [
{ field: "company" },
{ field: "department", aggregates: [ { field: "headcount", aggregate: "sum" }] }
]
}
});
</script>
How can I achieve correct multi level summing in a kendo grid?
The sums for the subgroups appear ok.
But the sums for the groups are wrong - they show the sum for all records instead of the sum per group.
This can be reproduced by pasting the code below in one of the demo areas in
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "company", groupHeaderTemplate: "#= value #" },
{ field: "department", groupHeaderTemplate: "#= value #" },
{ field: "headcount", groupFooterTemplate: "#= sum #", footerTemplate: "#= sum #" }
],
dataSource: {
data: [
{ company: "IBM", department: "Software", headcount: 4000 },
{ company: "IBM", department: "Software", headcount: 5000 },
{ company: "Apple", department: "Hardware", headcount: 2000 },
{ company: "IBM", department: "Hardware", headcount: 7000 },
{ company: "Apple", department: "Software", headcount: 6000 }
],
aggregate: [
{ field: "headcount", aggregate: "sum" }
],
group: [
{ field: "company" },
{ field: "department", aggregates: [ { field: "headcount", aggregate: "sum" }] }
]
}
});
</script>
How can I achieve correct multi level summing in a kendo grid?