Hi,
I'm using a Kendo Grid with MVVM bindings. In my schema I have an ID field defined. When I call the create server call a new record is created. A structure is then returned from WS with one property which is the new records ID. My code is:
var myDS = new kendo.data.DataSource({
schema: {
model: {
id: "GROUP_ID",
fields: {
"GROUP_ID": {
type: "number"
},
"DESCRIPTION": {
type: "string"
},
}
}
},
pageSize: 20,
batch: false,
transport: {
read:{
url: "/Role/GetRoles"
},
update: {
url: "/Role/Update"
contentType: "application/json",
type: "POST"
},
destroy: {
url: "/Role/Delete"
contentType: "application/json",
type: "POST",
},
create: {
url: "/Role/Create"
contentType: "application/json",
type: "POST",
},
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify(data);
} else {
return JSON.stringify(data); //return stringified options to the server
}
}
}
});
var vm = kendo.observable({
groupData: myDS
});
$("#grid").kendoGrid({
columns: [
{ "field": "DESCRIPTION", "title": "Group Name" },
{ "command": "edit" },
{ "command": "destroy" },
],
pageable: true,
navigatable: true,
toolbar: ["create"],
editable: { "mode": "popup", "template": $("#popup_editor").html()},
});
kendo.bind($('#grid'), vm);
I am having several problems
1) If my web service (in this case a C# MVC controller) returns anything at all I get javascript errors, the create dialog does not disappear. If I change it to have a void return type everything works.
2) If I edit a record after creating the Update call to my web service is never made.
I think both issues are related in that I want to be able to sync the new ID of the newly created record back with the grid.
I'm using a Kendo Grid with MVVM bindings. In my schema I have an ID field defined. When I call the create server call a new record is created. A structure is then returned from WS with one property which is the new records ID. My code is:
var myDS = new kendo.data.DataSource({
schema: {
model: {
id: "GROUP_ID",
fields: {
"GROUP_ID": {
type: "number"
},
"DESCRIPTION": {
type: "string"
},
}
}
},
pageSize: 20,
batch: false,
transport: {
read:{
url: "/Role/GetRoles"
},
update: {
url: "/Role/Update"
contentType: "application/json",
type: "POST"
},
destroy: {
url: "/Role/Delete"
contentType: "application/json",
type: "POST",
},
create: {
url: "/Role/Create"
contentType: "application/json",
type: "POST",
},
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify(data);
} else {
return JSON.stringify(data); //return stringified options to the server
}
}
}
});
var vm = kendo.observable({
groupData: myDS
});
$("#grid").kendoGrid({
columns: [
{ "field": "DESCRIPTION", "title": "Group Name" },
{ "command": "edit" },
{ "command": "destroy" },
],
pageable: true,
navigatable: true,
toolbar: ["create"],
editable: { "mode": "popup", "template": $("#popup_editor").html()},
});
kendo.bind($('#grid'), vm);
I am having several problems
1) If my web service (in this case a C# MVC controller) returns anything at all I get javascript errors, the create dialog does not disappear. If I change it to have a void return type everything works.
2) If I edit a record after creating the Update call to my web service is never made.
I think both issues are related in that I want to be able to sync the new ID of the newly created record back with the grid.