I have the following complex JSON object representing a car and its sales data:
"cars" : [ {
"model" : {
"name" : "Toyota",
"make" : [{
"name" : "Camry"
"yearSales" : [{
"vehicleYear": 2010
"salesData" : {
"oneYear" : 5.4
"twoYear" : 4.2
"threeYear" : 8.1
}
}...],...]
},...
In a Kendo grid I would like to represent this as follows:
I know that I can flatten the complex object into a kendo model. I can then tell Kendo to group that data and display in a kendo grid:
return new kendo.data.DataSource({
transport: {
read: {
url: "/car-sales",
type: "GET",
dataType: "json",
contentType: "application/json",
cache: false
}
},
schema: {
model: {
fields: {
"modelName": {from: "model.name", type: "string"},
"makeName": {from: "model.make.name", type: "string"},
....
}
}
},
group: [{
field: "modelName"
},{
field: "makeName"
}], ...
Instead of flattening the object and then having kendo do client side grouping, is it possible to tell kendo to group based on the original JSON object structure? That is, use the top most parent property model for first level grouping, use make for second level grouping" and then have individual rows to be vehicleYear.
from Can Kendo grid group by a JSON parent property?

No comments:
Post a Comment