Using MY WCF Service I expose JSON data:
[OperationContract]
[WebGet(ResponseFormat=WebMessageFormat.Json)]
List<ProductDetails> GetProductDetails();
Here is an example of the returned JSON:
{"d": [{"__ type": "Product Details: #NWProducts", "Discount": 0, "OrderId": 10248, "ProductID": 11, "UnitPrice": 14.0000, "Quanity": 12}, {"__ type": "Product Details: #NWProducts", "Discount": 0, "OrderId": 10248, "ProductID": 42, "UnitPrice": 9.8000, "Quanity": 10}, {"__ type": "#NWProducts: Product Details", "discount": 0, "OrderId": 10248, "ProductID": 72, "UnitPrice": 34.8000, "Quanity": 5}, {"__ type ":": #NWProducts Product details "," Discount ": 0," OrderId ": 10249," ProductID ": 14," UnitPrice ": 18.6000," Quanity ": 9}, {" __ type ": "Product Details: #NWProducts "," discount ": 0," OrderId ": 10249," ProductID ": 51," UnitPrice ": 42.4000," Quanity ": 40}
Trying to connect this to a Kendo grid using:
<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>
For some reason, I cannot see any data in the grid. Maybe something is wrong with the way I am trying to relate my data.