Reputation: 3317
We've asp.net web api odata enabled service which supports variety of OData formats such as application/json;odata=fullmetadata
This services is working great with WCF Data Service Client and JayData
But our response seems not to be compatible with our kendo grid dataSource
I've investigated the response and here is the difference:
The demo of kendoUI site which is working fine has following response:
"__count": "91"
And the response content type is: text/javascript;charset=utf-8
You can see the sample of kendo UI demo at:
http://demos.kendoui.com/web/grid/index.html
And here is our response:
"odata.metadata":"http://localhost:2452/odata/$metadata#VehicleGroups","odata.count":"29","value":[
And the response content type is: application/json; odata=fullmetadata; charset=utf-8
Can I have a ODataMediaTypeFormatter that generates needed format? Or is there any solution to make KendoDataSource works with our current response? Any other solutions are appreciated.
Note that we've enabled OData for KendoDataSource with type: "odata"
Thanks
Upvotes: 2
Views: 2418
Reputation: 3317
This is because KendoUI still communicates in the OData V2 format and your server is operating with OData V3.
To solve this problem you can use V2 on your server side or refine how the KendoUI transport processes the response by adding the following configuration to the data source object:
schema: {
data: function (data) {
return data.value;
},
total: function (data) {
return data['odata.count'];
}
},
So kendo grid will understand that total will be at totalCount section of the response instead of "__count"
Upvotes: 5