I'm trying to load a two level structure into a treeview control.
The structure is like a calendar in that there is a date, followed by 1 or more events on that date.
They problem I have is that it displays correctly using a local array, but not when I get the data from an external source. The
two hierarchical definitions follow:
window.calendarData = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "https://admin.medinet.ca/cgi-non/mmb/json_calendar.cgi",
dataType: "json"
}
},
schema: {
model: {
id: "eventId",
hasChildren: "items",
fields: {
eventId: {
editable: false
},
date: {
editable: true
},
items: {
model: {
id: "eventId",
fields: {
eventId: {
editable:false
},
lastname: {
type: "string",
editable: true
}
}
}
}
}
}
}
});
window.calendarDataLocal = new kendo.data.HierarchicalDataSource({
data: [
{
eventId: 0,
date: '2015-08-01',
items: [
{
eventId: 1,
lastname: "poulin",
},
{
eventId: 2,
lastname: "smith",
}
]
},
{
eventId: 3,
date: '2015-08-02',
items: [
{
eventId: 4,
lastname: "jones"
}
]
}
]
});
I'm pretty sure it has to do with my model definition, so if I'm doing something wrong in there please point me in the right direction. I've tried a number of different approaches but so far no luck.
The result I'm seeing is that the for local array the control works as expected, But the remote dataSource shows only the top level nodes and undefined for the lower level nodes.
Here is the div for displaying it.
<div id="mainCalendar">
</div>
<script>
$(document).ready(function () {
$("#mainCalendar").kendoTreeView({
dataSource: window.calendarData,
dataTextField: ["date", "lastname"]
})
});
</script>
Note that the dataTextField uses different name for each level.
Here is a copy of the data as returned from the remote source.
[{
"date":"2015-08-11",
"eventId":0,
"items":[{
"firstname":"Fred",
"stopTime":"11:00",
"startTime":"10:30",
"lastname":"Flintstone",
"type":"paid",
"eventId":1
},
{
"stopTime":"12:44",
"actvity":"lunch",
"startTime":"12:00",
"type":"unpaid",
"eventId":1
}]
},
{"date":"2015-08-12",
"eventId":3,
"items":[{
"firstname":"Kermit",
"lastname":"Frog",
"type":"paid",
"eventId":4
}]
}]
Any help would be appreciated.