【发布时间】:2014-03-21 09:24:01
【问题描述】:
使用我的 WCF 服务我正在公开 JSON 数据:
[OperationContract]
[WebGet(ResponseFormat=WebMessageFormat.Json)]
List<ProductDetails> GetProductDetails();
这里是返回的 JSON 示例:
{"d":[{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":11,"UnitPrice":14.0000,"quantity":12 },{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":42,"UnitPrice":9.8000,"quantity":10},{"__type": "ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":72,"UnitPrice":34.8000,"quantity":5},{"__type":"ProductDetails:#NWProducts", "Discount":0,"OrderId":10249,"ProductId":14,"UnitPrice":18.6000,"quantity":9},{"__type":"ProductDetails:#NWProducts","Discount":0," OrderId":10249,"ProductId":51,"UnitPrice":42.4000,"quantity":40}
尝试使用以下方法将其绑定到 Kendo Grid:
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: "http://localhost/KendoServices/Web/GetProductDetails"
},
pageSize: 10
},
groupable: true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
field: "OrderId",
title: "OrderId",
width: 140
}, {
field: "ProductId",
title: "ProductId",
width: 190
}, {
field: "UnitPrice",
title: "UnitPrice"
}, {
field: "quanity",
width: 110
}]
});
});
</script>
由于某种原因,我无法在网格上看到任何数据。我尝试绑定数据的方式可能有问题。
【问题讨论】:
-
只是一个报价...尝试添加
ServerOperation:false
标签: c# json wcf kendo-ui kendo-grid