I've managed to get the groupings working. I need to do pretty much everything server side (grouping, aggregates, sorting, paging, filtering). However I am getting errors when trying to do an aggregate.
My json data is:
{
\"Count\":10,
\"ViewData\":[],
\"groups\":[
{
\"aggregates\":[
{
\"Tier\":{
\"count\":5
}
}
],
\"field\":\"Tier\",
\"value\":\"Tier 1\",
\"items\":[
{
\"ProductLine\":\"CART for Commuters\",
\"Component\":\"Marketing\",
\"Tier\":\"Tier 1\"
},
{
\"ProductLine\":\"CART for Commuters\",
\"Component\":\"Marketing\",
\"Tier\":\"Tier 1\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 1\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 1\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 1\"
}
],
\"hasSubgroups\":false
},
{
\"aggregates\":[
{
\"Tier\":{
\"count\":5
}
}
],
\"field\":\"Tier\",
\"value\":\"Tier 2\",
\"items\":[
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 2\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 2\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 2\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 2\"
},
{
\"ProductLine\":\"Platinum\",
\"Component\":\"Help Content\",
\"Tier\":\"Tier 2\"
}
],
\"hasSubgroups\":false
}
],
\"aggregates\":[
{
\"Tier\":{
\"count\":10
}
}
],
\"ErrorMessage\":null,
\"Success_Flag\":true
}
My code looks like:
$("#grid").kendoGrid({
dataSource: {
type: "json",
serverPaging: true,
serverSorting: true,
serverGrouping: true,
serverAggregates: true,
pageSize: 100,
transport: {
read: "http://localhost:6332/api/View?ViewID=222"
},
schema: { data: "ViewData", total: "Count", groups: "groups", aggregates: "aggregates"},
group: {
field: "Tier", aggregates: [{ field: "Tier", aggregate: "count" }]
}
},
height: 780,
scrollable: true,
sortable: false,
pageable: true,
columns: colList
});
I am trying to create an aggregate on a column named Tier, the column is defined as:
var tiercol= {field:"Tier", title:"Tier", aggregates: ["count"], groupFooterTemplate: "Count: #=count#" };
When I do this I get an error:
Uncaught TypeError: undefined has no properties
As far as I can see my data is correct. What am I doing wrong with the aggregate function. If I remove the aggregates stuff from the column definition the page renders without error (with no aggregate obviously) so it's definitely the aggregate that causes the problem.