I have a grid which need to make an update through POST and not GET. SO I am doing this on Save event. Everything works fine with inline editing. But with PopUp editing I do not get referance to model. So in function " save: function (e)" below e.model is undefined. However it comes up fine in case of inline.
If there is better way to update the drid through POST then I am open to it.
here is the code:
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: URL,
dataType: "jsonp"
},
update: {
url: "",
dataType: "jsonp"
},
destroy: {
url: "",
dataType: "jsonp"
},
create: {
url: "",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 10,
schema: {
model: {
id: "PROJECT_ID",
fields: {
"PROJECT_ID": { editable: false, nullable: true },
"PROJECT_NM": { validation: { required: true} },
"PROJECT_DESC": { validation: { required: true} },
"ACTIVE_IND": { type: "boolean" }
}
}
}
});
//GRID
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 400,
toolbar: ["create"],
columns: [
{ field: "PROJECT_ID", title: "ID" },
{ field: "PROJECT_NM", title: "Name" },
{ field: "PROJECT_DESC", title: "Description" },
{ field: "ACTIVE_IND", title: "Active" },
{ command: ["edit"], title: " "}],
editable: "popup",
save: function (e) {
var g = $("#grid").data("kendoGrid");
var ds = g.dataSource;
var refresh = false;
//alert(kendo.stringify(e.model));
var url = "";
e.model.ACTIVE_IND = e.model.ACTIVE_IND ? 1 : 0
$.ajax({
url: url,
data: kendo.stringify(e.model),
type: 'POST',
processData: true,
async: false,
contentType: "application/json",
success: function (data, textStatus, jqXHR) {
alert("Updated")
},
error: function (xhr, status, error) {
alert("Failed to Update");
}
});
}
});