I have an MVC application using a Kendo grid as follows:
var products = [{
ProductID: 1,
FullName: "Chai",
IsHeadmaster: "T"
}];
$("#teachers").kendoGrid({
dataSource: {
type: "json",
transport: {
read: function (e) {
// on success
e.success(products);
// on failure
//e.error("XHR response", "status code", "error message");
},
update: {
type: "POST",
url: "/Home/UpdateTeachers",
dataType: "json",
contentType: "application/json"
},
parameterMap: function(data, operation) {
if (operation === "update" || operation === "create") {
return JSON.stringify({product: data});
}
return data;
}
},
batch: true,
schema: {
model: {
id: "TeacherId",
fields: {
TeacherId: { type: "number" },
FullName: { type: "string" },
IsHeadmaster: { type: "boolean" }
}
}
}
},
toolbar: ["create", "save"],
columns: [
{ field: "FullName", title: "Teacher" },
{ field: "IsHeadmaster", title: "Is a Headmaster?", width: "120px" },
{ command: ["destroy"], title: " ", width: "85px" }],
editable: true
});
And my controller as:
public JsonResult UpdateTeachers(string models)
{
// do update here
}
The grid loads and displays perfectly, however when i try to make an edit and update i get the following error:
Unhandled exception at line 6684, column 17 in http://localhost:5227/kendo/js/kendo.web.js
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'call'
I'm using JQuery 1.8.2.
Any ideas/help would be greatly appreciated?
You may try this by editing below code
instead of
return JSON.stringify({product: data});
use
return { models: kendo.stringify(data.models) };
User contributions licensed under CC BY-SA 3.0