I'm having issues with a Datasouce when using a JSON service/data. I constantly get an error telling me that any of my fields are undefined. According to Fiddler, result is returned as JSON and is correctly formatted. This the same issue I'm having here: http://www.kendoui.com/forums/ui/autocomplete/weird-problem-with-autocomplete.aspx
As per the above post, the solution works fine in jsFiddle but NOT in the real world.
I'm creating my grid like this:
Here is the data returned:
I'm just guessing it is because the data isn't layed out like this:
I could be wrong, but looking around these forums, everone who seems to have the 'undefined' issue on fields seem to have their JSON similar to how mine is returned. I have another datasource with data in the directly above format returned from a service that works...
Does the data returned need to be parsed or stringified before use? I'm using MS's JSON formattes which encode data and return as a string. This is being written directly to the response stream. Strange as Fiddler can understand it just fine.
As per the above post, the solution works fine in jsFiddle but NOT in the real world.
I'm creating my grid like this:
$(
"#gridTitles"
).kendoGrid({
dataSource: {
type:
"json"
,
transport: {
read:
"../services/getTitles"
,
parameterMap:
function
(options) {
return
$.extend(options, {
collection: collection
});
}
},
schema: {
model: {
fields: {
Title: { type:
"string"
},
OFLC: { type:
"string"
}
}
}
},
pageSize: 10,
serverPaging:
true
,
serverSorting:
true
},
height: 250,
sortable:
true
,
pageable:
true
,
columns: [{ field:
"Title"
, title:
"Title"
}, { field:
"OFLC"
, title:
"Rating"
}]
});
Here is the data returned:
[{"Title":"Doctor Who and the Daleks","OFLC":"PG"},{"Title":"Doctor Who: Attack of the Cybermen","OFLC":"M"},{"Title":"Doctor Who: Battlefield","OFLC":"PG"},{"Title":"Doctor Who: Beneath the Surface - The Silurian Collection","OFLC":"PG"},{"Title":"Doctor Who: Black Orchid","OFLC":"PG"}]
I'm just guessing it is because the data isn't layed out like this:
{[
"SOME KEY"
: [{
"Title"
:
"something here..."
,
"oflc"
:
"something here..."
}]
}
I could be wrong, but looking around these forums, everone who seems to have the 'undefined' issue on fields seem to have their JSON similar to how mine is returned. I have another datasource with data in the directly above format returned from a service that works...
Does the data returned need to be parsed or stringified before use? I'm using MS's JSON formattes which encode data and return as a string. This is being written directly to the response stream. Strange as Fiddler can understand it just fine.