Using a kendoGrid with an xml datasource and serverAggregates, defining "aggregate" throws an error "Object [object Object] has no method 'aggregates'"
I am including a code example below. It works if you remove the "aggregate: [{field: "qty", aggregate: "sum"}],".
Here is the itemReport.xml datasource:
<xml version="1.0" encoding="UTF-8">
<page>
<items>
<item itemName="testitem" qty="2" />
<item itemName="Garlic Rolls 1(dozen)" qty="1" />
<item itemName="Triple Dipper" qty="1" />
<item itemName="Classic Bacon Burger" qty="1" />
<item itemName="Classic Chicken" qty="5" />
</items>
<aggregates>
<qty>
<sum>18</sum>
</qty>
</aggregates>
<total val="7"/>
</page>
And the page source:
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example" class="k-content">
<div id="grid"></div>
</div>
<script>
$(document).ready(function() {
var grid = $("#grid").kendoGrid({
dataSource: {
transport: {
read: "itemReport.xml",
cache: false
},
schema: {
type: "xml",
data: "/page/items/item",
aggregates: "/page/aggregates",
model: {
fields: {
itemName: "@itemName",
qty: "@qty"
},
},
total: "/page/total/@val",
},
serverAggregates: true,
aggregate: [{field: "qty", aggregate: "sum"}],
pageSize: 5,
serverPaging: true,
serverSorting: true,
serverFiltering: true
},
height: 450,
sortable: true,
pageable: true,
reorderable: true,
resizable: true,
columns: [
{
field: "itemName",
title: "Item"
},
{
field: "qty",
title: "Sold"
}
]
});
});
</script>
</body>
</html>
I am including a code example below. It works if you remove the "aggregate: [{field: "qty", aggregate: "sum"}],".
Here is the itemReport.xml datasource:
<xml version="1.0" encoding="UTF-8">
<page>
<items>
<item itemName="testitem" qty="2" />
<item itemName="Garlic Rolls 1(dozen)" qty="1" />
<item itemName="Triple Dipper" qty="1" />
<item itemName="Classic Bacon Burger" qty="1" />
<item itemName="Classic Chicken" qty="5" />
</items>
<aggregates>
<qty>
<sum>18</sum>
</qty>
</aggregates>
<total val="7"/>
</page>
And the page source:
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example" class="k-content">
<div id="grid"></div>
</div>
<script>
$(document).ready(function() {
var grid = $("#grid").kendoGrid({
dataSource: {
transport: {
read: "itemReport.xml",
cache: false
},
schema: {
type: "xml",
data: "/page/items/item",
aggregates: "/page/aggregates",
model: {
fields: {
itemName: "@itemName",
qty: "@qty"
},
},
total: "/page/total/@val",
},
serverAggregates: true,
aggregate: [{field: "qty", aggregate: "sum"}],
pageSize: 5,
serverPaging: true,
serverSorting: true,
serverFiltering: true
},
height: 450,
sortable: true,
pageable: true,
reorderable: true,
resizable: true,
columns: [
{
field: "itemName",
title: "Item"
},
{
field: "qty",
title: "Sold"
}
]
});
});
</script>
</body>
</html>