Kendo ui 使用具有数组的对象的Kendo UI ListView
如何让ListView循环对象属性Kendo ui 使用具有数组的对象的Kendo UI ListView,kendo-ui,kendo-listview,Kendo Ui,Kendo Listview,如何让ListView循环对象属性timetableRecords。我在谷歌搜索,但找不到方法 数据示例(招摇过市响应模型模式): { "from": { "name": "string" }, "to": { "name": "string" }, "price": 0, "date": "2016-07-25T11:52:52.674Z", "timetableRecords": [ { "departure": "2016-0
timetableRecords
。我在谷歌搜索,但找不到方法
数据示例(招摇过市响应模型模式):
{
"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"
}
<div id="timetableRecords"></div>
<script type="text/x-kendo-template" id="template">
<div class="timetable-record">
<p>#:departure#</p>
<p>#:arrival#</p>
</div>
</script>
$('#timetableRecords').kendoListView({
template: kendo.template($("#template").html()),
dataSource: {
transport: {
read: {
type: 'GET',
url: 'api/timetable?from=station_name1&to=station_name2',
dataType: 'json'
}
}
}
});
HTML:
{
"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"
}
<div id="timetableRecords"></div>
<script type="text/x-kendo-template" id="template">
<div class="timetable-record">
<p>#:departure#</p>
<p>#:arrival#</p>
</div>
</script>
$('#timetableRecords').kendoListView({
template: kendo.template($("#template").html()),
dataSource: {
transport: {
read: {
type: 'GET',
url: 'api/timetable?from=station_name1&to=station_name2',
dataType: 'json'
}
}
}
});
所以你发布这篇文章已经有一段时间了,但我有一个解决方案给你(怀疑你是否仍然需要它) schema.parse()事件可以帮助您: 在使用服务器响应之前执行。使用它来预处理或解析服务器响应 以下是您更新的数据源:
dataSource: {
transport: {
read: {
type: 'GET',
url: 'api/timetable?from=station_name1&to=station_name2',
dataType: 'json'
}
},
schema:
parse: fucntion(e) {
return e.timetableRecords
}
}
这样,您的数据源将处理“timetableRecords”列表,并且您的模板将是有效的
祝你好运
格兰特(Grant)你发布这篇文章已经有一段时间了,但我有一个解决方案给你(怀疑你是否还需要它) schema.parse()事件可以帮助您: 在使用服务器响应之前执行。使用它来预处理或解析服务器响应 以下是您更新的数据源:
dataSource: {
transport: {
read: {
type: 'GET',
url: 'api/timetable?from=station_name1&to=station_name2',
dataType: 'json'
}
},
schema:
parse: fucntion(e) {
return e.timetableRecords
}
}
这样,您的数据源将处理“timetableRecords”列表,并且您的模板将是有效的
祝你好运
授予