Hello, I try to use ig.RemoteDataSource and property responseDataKey (response in JSON) in IgniteUi 15.2. In many examples in the documentation, the property is used with the values "d" or "d.results". I can not use anything in replacement of "d". example: d.rows: OK d.test: OK data.rows: NOK Apparently this does not work when the root property is not "d". Thanks for your help
Hi GBAU,
It's my understanding that this is the default syntax for when an OData Service returns json. More details regarding this standard is available in the oData Documentation:http://www.odata.org/documentation/odata-version-2-0/json-format/ If you wish to change this, you will need to make the appropriate changes to your service.
I hope this helps. Please let me know if you have additional questions regarding this matter.
Hi,
Thanks for your reply but I'm frightened by your answer. I use a generic object RemoteDataSource, not a ODataRemoteDataSource if it exists. Why when using "results" or "otherKey" directly it works (though not in the OData specifications) while "otherKey1.otherKey2" does not? Thanks
Taking the following "Remote Data" sample as an example:https://www.igniteui.com/sparkline/bind-to-remote-data
Here, we are also setting the responseDataKey to 'd.results'. If you review the json sent to the client, you will see that the results are enclosed in the "d" object. This is due to the default configuration of the OData service we use to send the json data to the client, as we've learned in the help topic I referenced in my last update. Note, this syntax is set through the service and not the RemoteDataSource or ODataRemoteDataSource on the client. If you wish to alter the way the json is constructed, you will have to make the changes within your service which is outside of the IgniteUI components.
I have attached a screenshot which helps demonstrates what I was referencing in the sample. Please let me know if you have additional questions regarding this matter.
Hi, I think you have not understood my problem If my service returns this:
{ "data": { "rows": [{ "ProductID": "1", "ProductName": "Produit 1", "CategoryName": "Categorie 4", "ImageUrl": "./images/dummies/1.jpg", "InStock": "219" }, { "ProductID": "2", "ProductName": "Produit 2", "CategoryName": "Categorie 4", "ImageUrl": "./images/dummies/2.jpg", "InStock": "124" }] }}And I put "data.rows" the property "responseDataKey", it should work?Thanks
Indeed it works when I configure paging in "local" mode.
Thanks
Thank you for the sample you've provided as this gives us a better understanding of the issues you're encountering.
After reviewing your sample, I see that you're using the igGrid's Server Side Paging feature. To prevent the "Cannot read property '__count' of undefined" error you're currently encountering, I recommend settings the Paging Type option to "local" as this will prevent the igRemoteDataSource to getting the record count from the remote request.
Alternatively, if you're returning the record count through your request, I recommend setting the responseTotalRecCountKey option for the igRemoteDataSource accordingly. Note, this option is required when using remote paging.
Please let me know if you have additional questions regarding this matter.
I made an example.
It is based on this example: http://www.igniteui.com/grid/overview
I just added a remoteDataSource who call simply a .json file (IIS returns application/json as content-type with this extension) (in my real case it is a .ashx .NET)
Thanks for your help
Hello,
Thank you for the update. I have done some looking into this matter and testing and when I use a datasource with “data.rows” as the responseDataKey field it works without issue. Can you tell us more about your setup? What controls are you using with the datasource? Do you have an isolated sample that reproduces this behavior for you?