I feel like I'm taking crazy pills. I've seen this odata workaround in many places, but I can't for the life of me get it to work. I have a simple data source that loads from an odata Web Api v2 endpoint. The endpoint seems to be returning the JSON data appropriately, here's what I'm seeing as a response with only 2 items being returned:
And here's how my data source is defined:
And any time it fetches data I get the usual odata error:
Unable to get property '__count' of undefined or null reference
I've tried setting breakpoints on my data() and total() functions and they're never reached. I can't figure out why the usual internal total function is being called instead of mine. The error occurs in:
I can't figure out what I'm missing here?
{
"odata.metadata"
:
"http://localhost:40946/odata/$metadata#AlbumThumbnail"
,
"odata.count"
:
"2"
,
"value"
:[
{
"ImageId"
:29,
"Title"
:
null
},
{
"ImageId"
:30,
"Title"
:
null
}
]
}
And here's how my data source is defined:
var
thumbnailSource =
new
kendo.data.DataSource({
type:
"odata"
,
transport: {
read: {
url:
"/odata/AlbumThumbnail/"
,
dataType:
"json"
,
data: {
id: 31
}
},
schema: {
data:
function
(data) {
return
data.value;
},
total:
function
(data) {
return
data[
"odata.count"
];
},
model: {
fields: {
ImageId: { type:
"number"
}
}
}
}
}
});
$(window).load(
function
() {
thumbnailSource.read();
});
And any time it fetches data I get the usual odata error:
Unable to get property '__count' of undefined or null reference
I've tried setting breakpoints on my data() and total() functions and they're never reached. I can't figure out why the usual internal total function is being called instead of mine. The error occurs in:
function
anonymous(d) {
return
d.d.__count
}
I can't figure out what I'm missing here?