I have a OData service that returns the following json.
I need to convert the json into a Kendo datasource that can be bound to a read-only grid.
Here is the json.
{
"@odata.context":"http://localhost/DataService/Data","value":[
{"ID":1,"Description":"Test 1"}
,{"ID":2,"Description":"Test 2"}
,{"ID":3,"Description":"Test 3"}]
}
I have tried something as simple as the following but this does not work.
I have used fiddler and I am seeing the json getting returned correctly.
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "http://localhost/DataService/Data",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl,
dataType: "json",
type: "POST"
},
parameterMap: function (data, operation) {
alert(JSON.stringify(data));
return JSON.stringify(data);
},
autoSync: false,
schema: {
model: {
id: "ID"
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
columns: [
{ field: "ID", title: "ID", width: 70 }]
});
});
</script>
I used the following online fiddle as a test and it worked fine when using local "echo".
http://jsfiddle.net/valchev/AC9tV/
I have also posted the question here.
http://stackoverflow.com/questions/26130634/kendo-datasource-odata-custom-json
I need to convert the json into a Kendo datasource that can be bound to a read-only grid.
Here is the json.
{
"@odata.context":"http://localhost/DataService/Data","value":[
{"ID":1,"Description":"Test 1"}
,{"ID":2,"Description":"Test 2"}
,{"ID":3,"Description":"Test 3"}]
}
I have tried something as simple as the following but this does not work.
I have used fiddler and I am seeing the json getting returned correctly.
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "http://localhost/DataService/Data",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl,
dataType: "json",
type: "POST"
},
parameterMap: function (data, operation) {
alert(JSON.stringify(data));
return JSON.stringify(data);
},
autoSync: false,
schema: {
model: {
id: "ID"
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
columns: [
{ field: "ID", title: "ID", width: 70 }]
});
});
</script>
I used the following online fiddle as a test and it worked fine when using local "echo".
http://jsfiddle.net/valchev/AC9tV/
I have also posted the question here.
http://stackoverflow.com/questions/26130634/kendo-datasource-odata-custom-json