【发布时间】:2013-11-19 15:49:27
【问题描述】:
我正在使用 Kendo UI Listview 控件来显示来自 WCF 服务的类别数据。问题始终是列表视图,而不是显示类别的“名称”,而是显示 [object Object]。
服务返回的Json数据是这样的
d
Items
ID=1
Name=Sports
IsActive=true
HTML 代码:
<body>
<div data-role="view" data-init="mobileListViewPullWithEndless">
<ul id="grouped-listview"></ul>
</div>
<script>
var categoriesTransport = new kendo.data.RemoteTransport({
read: {
url: "http://localhost:11124/Services/PublishingMobileService.svc/GetAllCategories", //specify the URL which data should return the records. This is the Read method of the Products.svc service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
dataType: 'json',
type: "POST" //use HTTP POST request as the default GET is not allowed for svc
},
parameterMap: function (data, operation) {
if (operation != "read") {
// web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
return JSON.stringify(data);
} else {
return JSON.stringify(data);
}
}
});
function mobileListViewPullWithEndless(e) {
$("#grouped-listview").kendoMobileListView({
height: 400,
dataSource:kendo.data.DataSource.create( {
schema: {
data: "d.Items", // svc services return JSON in the following format { "d": <result> }. Specify how to get the result.
},
transport: categoriesTransport,
template: $("#endless-scrolling-template").text(),
}),
});
}
</script>
<script type="text/x-kendo-tmpl" id="endless-scrolling-template">
<div>
<h3>#:ID#</h3>
</div>
</script>
<script>
var app = new kendo.mobile.Application(document.body);
</script>
你能帮忙吗?
【问题讨论】:
标签: wcf listview kendo-mobile