I'm trying to use server grouping in a grid.
I'm not sure about the difference between "schema.groups" and "schema.data". I understand that i should use shema.data when data are not grouped, and schema.groups when data are grouped. I tryied to provide a very simple example, with a ajax request to a data.json file to simulate a server response. Just drop the testGrouping.html and data.json files in the root of any http server to reproduce my problem.
When i run the given code, i have no error, but the grid remains empty. I expect the grid to show 1 group with 5 lines, without any aggregate.
Could you help to find what's wrong in the given sample ?
Thank you for your help.
Here is the html page i'm using (testGrouping.html) :
<!DOCTYPE html>
<html>
<head>
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.material.mobile.min.css" />
<script src="https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js"> </script>
</head>
<body>
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "data.json?x=1",
cache:false,
type: 'GET',
dataType: 'json',
contentType: "application/json"
},
},
error: function(e) {
console.log(e.errors); // displays "Invalid query"
},
schema:{
// "data":"titi",
"groups":"groups",
"total": "total",
"model": {
"fields": [
{
"field": "m2"
},
{
"field": "m"
},
]
}
},
pageSize: 7
},
sortable: true,
scrollable: false,
pageable: true,
serverPaging: true,
serverAggregates: true,
serverFiltering: true,
serverGrouping: true,
serverSorting: true,
columns: [
{
"field": "m2",
"title": "Group odd / even"
},
{
"field": "m",
"title": "Month"
}
]
});
});
</script>
</div>
And data used here to simulate server response (data.json) :
{
"total":1,
"groups":
[ {
"aggregates": [],
"value": "rrr",
"hasSubgroups": false,
"field": "m2",
"items": [
{
"m2": "rrr",
"m": 1
},
{
"m2": "rrr",
"m": 1
},
{
"m2": "rrr",
"m": 1
},
{
"m2": "rrr",
"m": 1
},
{
"m2": "rrr",
"m": 1
}
],
"aggregates": {}
}]
}