Hi,
I'm getting an error when I have a an ODATA DataSource with a transport that has Create defined. Here is a JSFiddle showing the error. It doesn't matter what the URL is set to, it never reaches the point of using it. If you open the console you will see the error.
http://jsfiddle.net/cpomer/qmX55/6/
Any help would be appreciated.
Thanks,
Chris
I'm getting an error when I have a an ODATA DataSource with a transport that has Create defined. Here is a JSFiddle showing the error. It doesn't matter what the URL is set to, it never reaches the point of using it. If you open the console you will see the error.
http://jsfiddle.net/cpomer/qmX55/6/
Any help would be appreciated.
Thanks,
Chris
4 Answers, 1 is accepted
0
Hello Chris,
I can see that you have specified type:odata in your DataSource declaration. Using odata requires some additional fields in the response from the service such as "__count". So if no "__count" is provided in the server response than you get the error that you are experiencing. I can also see that in your create configuration you are specifing dataType: json, please keep in mind that such configuration is not recommended. You can either use odata or json, but not the two data types simultaneously.
In your case if you want to use odata, please make sure that you are really using odata service, or implement the total configuration like in this jsBin.
Regards,
Kiril Nikolov
Telerik
I can see that you have specified type:odata in your DataSource declaration. Using odata requires some additional fields in the response from the service such as "__count". So if no "__count" is provided in the server response than you get the error that you are experiencing. I can also see that in your create configuration you are specifing dataType: json, please keep in mind that such configuration is not recommended. You can either use odata or json, but not the two data types simultaneously.
In your case if you want to use odata, please make sure that you are really using odata service, or implement the total configuration like in this jsBin.
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

Chris
Top achievements
Rank 1
answered on 15 Aug 2013, 04:48 AM
Hi Kiril,
My data source is ODATA, it's a WCF service. I seemed to have problems if I didn't put JSON as the dataType on the Transport. But I will try it without that to see if it still works. Everything else is working fine for me though even when configured like that. I have many other DataSources that work.
If you look at my problem though I am not trying to retrieve any data at all. I simply want to create a new DataSource, add a new record, and have that record sent to the server. The DataSource attempts to access the __count property but the data object it's trying to get the __count on doesn't exist yet. If I do a read() first then everything is fine, but I don't want to do that, I just want to create a new record.
Thanks,
Chris
My data source is ODATA, it's a WCF service. I seemed to have problems if I didn't put JSON as the dataType on the Transport. But I will try it without that to see if it still works. Everything else is working fine for me though even when configured like that. I have many other DataSources that work.
If you look at my problem though I am not trying to retrieve any data at all. I simply want to create a new DataSource, add a new record, and have that record sent to the server. The DataSource attempts to access the __count property but the data object it's trying to get the __count on doesn't exist yet. If I do a read() first then everything is fine, but I don't want to do that, I just want to create a new record.
Thanks,
Chris
0

Chris
Top achievements
Rank 1
answered on 15 Aug 2013, 05:13 AM
I ended up adding these to my schema to keep it from generating errors.
Maybe I'm using the DataSource in a way not intended but it seemed like the easiest way for me to reuse code I had already created.
Thanks,
Chris
total: function (response) {
return (response && response.d ? response.d.__count : 0);
},
data: function(data) {
return (data && data.d ? (data.d.results || [data.d]) : []);
}
Thanks,
Chris
0
Hello Chris,
You are using the DataSource correctly. But the oData service that you use is not adding the count and result properties to the response. When oData is specified as a type in the DataSource, it is configured to expect the total and count properties, and if they are missing you get errors like the one you got.
The workaround is to implement the count and result properties yourself (as you already did), and this is what we usually suggest when a user gets to this kind of problem.
If you need anything else, please do not hesitate to contact us.
Regards,
Kiril Nikolov
Telerik
You are using the DataSource correctly. But the oData service that you use is not adding the count and result properties to the response. When oData is specified as a type in the DataSource, it is configured to expect the total and count properties, and if they are missing you get errors like the one you got.
The workaround is to implement the count and result properties yourself (as you already did), and this is what we usually suggest when a user gets to this kind of problem.
If you need anything else, please do not hesitate to contact us.
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!