如何让我的 ListView 循环遍历对象属性timetableRecords
。我正在谷歌搜索,但找不到方法。
数据示例(swagger 响应模型架构):
{
"from": {
"name": "string"
},
"to": {
"name": "string"
},
"price": 0,
"date": "2016-07-25T11:52:52.674Z",
"timetableRecords": [
{
"departure": "2016-07-25T11:52:52.675Z",
"arrival": "2016-07-25T11:52:52.675Z"
}
],
"fetchedOn": "2016-07-25T11:52:52.675Z"
}
HTML:
<div id="timetableRecords"></div>
<script type="text/x-kendo-template" id="template">
<div class="timetable-record">
<p>#:departure#</p>
<p>#:arrival#</p>
</div>
</script>
JavaScript:
$('#timetableRecords').kendoListView({
template: kendo.template($("#template").html()),
dataSource: {
transport: {
read: {
type: 'GET',
url: 'api/timetable?from=station_name1&to=station_name2',
dataType: 'json'
}
}
}
});