Hi all!
Regarding to a API reference for Kendo (proof:
Kendo UI API Reference - Schema.Model.Children), children nodes can be declare in next approach (see nested 'schema' as 'define options for second level'):
var datasource = new kendo.data.HierarchicalDataSource({
data: [
{
categoryName: "SciFi",
movies: [
{ title: "Star Wars: A New Hope", year: 1977, cast: [
{ actor: "Mark Hamill", character: "Luke Skywalker" },
{ actor: "Harrison Ford", character: "Han Solo" },
{ actor: "Carrie Fisher", character: "Princess Leia Organa" }
] },
{ title: "Star Wars: The Empire Strikes Back", year: 1980, cast: [
{ actor: "Mark Hamill", character: "Luke Skywalker" },
{ actor: "Harrison Ford", character: "Han Solo" },
{ actor: "Carrie Fisher", character: "Princess Leia Organa" },
{ actor: "Billy Dee Williams", character: "Lando Calrissian" }
] }
]
}
],
schema: {
model: {
children: {
schema: {
data: "movies",
model: {
children: "cast"
}
}
}
}
}
});
I use similar definition for HierarchicalDataSource and get children nodes in that way:
schema: {
model: {
id: "urb_fltr",
hasChildren: true,
children: "PhoneCalls"
},
parse: function (data) {
var outRes = [];
var dataRes = [];
var tmpLoop = 0;
var bordNum = 251170009;
if (data.d.results != null && data.d.results.length > 0)
for (var step = 0; step < data.d.results.length; step++) {
if (data.d.results[step] == null) continue;
var stepData = data.d.results[step];
var stepValue = (stepData.urb_subject != null) ? stepData.urb_subject.Value : 0;
var arrValue = (stepValue > bordNum) ? stepValue - bordNum : 0;
if (outRes[arrValue] == null || typeof (outRes[arrValue]) == 'undefined') {
outRes[arrValue] = {};
outRes[arrValue].urb_total = 1;
outRes[arrValue].urb_clnts = 0;
outRes[arrValue].OwnerId = stepData.OwnerId;
outRes[arrValue].urb_subjectValue = stepValue;
outRes[arrValue].PhoneCalls = [];
}
else
outRes[arrValue].urb_total += 1;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1] = {};
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CallId = stepData.ActivityId;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].urb_name = stepData.urb_name;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CreatedOn = stepData.CreatedOn;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].PhoneNumber = stepData.PhoneNumber;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].ScheduledEnd = stepData.ScheduledEnd;
if (stepData.RegardingObjectId != null && stepData.RegardingObjectId.Id != null && stepData.RegardingObjectId.LogicalName == "lead") {
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].RegardingObjectId = stepData.RegardingObjectId;
outRes[arrValue].urb_clnts += 1;
}
}
for (var loop = 0; loop < outRes.length; loop++)
if (typeof (outRes[loop]) != 'undefined') {
outRes[loop].urb_subjectName = outRes[loop].urb_subjectName + " ( " + outRes[loop].urb_total + " - " + outRes[loop].urb_clnts + " )";
dataRes[tmpLoop] = outRes[loop];
tmpLoop++;
}
return dataRes;
},
type: "json"
}
It's OKay and I can see children in that way. But by default, property of 'hasChildren' is 'true' and I make scheme for children like in API reference:
children: {
schema: {
data: "PhoneCalls",
model: {
hasChildren: false
}
}
}
, and quite lose children.
Can anyone help define children property with scheme correctly?