I have a destroy command defined in one of the columns for a Kendo Grid:
columns: [
{
field: "Address",
width: "200px"
},
{
field: "City"
},
{
field: "State",
width: "40px"
},
{
field: "Zip",
width: "60px"
},
{
field: "Active",
width: "50px"
},
{
command: ["edit", "destroy"],
title: " ",
width: "210px"
}
]
Editable is set to inline for the grid. Batch is set to true for the datasource.
Editing and saving works fine (all models are sent in JSON format to SAVE method).
But when I click on DELETE for one of the rows, it removes the row from the grid BUT it behaves just like I was saving all items. It calls the save method and sends every single row, except for the one I want to delete, in a JSON object.
The question is: Why is it not calling the destroy method?
Shouldn't it call the destroy method and send only the row being deleted?
Datasource definition:
dataSource: {
error : function (e) {
CustomError(e);
},
type : "json",
transport: {
read : {
contentType: "application/json; charset=utf-8",
type : "POST",
url : "../Services/svcPerson_Address.asmx/Search",
dataType : "json",
cache : false,
complete : function (e) {
//alert(e);
}
},
update : {
contentType: "application/json; charset=utf-8",
type : "POST",
url : "../Services/svcPerson_Address.asmx/Save",
dataType : "json",
cache : false,
complete : function (e) {
if (typeof (e.responseText) != "undefined") {
var response = $.parseJSON(e.responseText);
}
}
},
destroy : {
contentType: "application/json; charset=utf-8",
url : "../Services/svcPerson_Address.asmx/Delete",
type : "POST",
dataType : "json",
cache : false,
complete : function (e) {
}
},
create : {
contentType: "application/json; charset=utf-8",
type : "POST",
url : "../Services/svcPerson_Address.asmx/Save",
cache : false,
complete : function (e) {
if (typeof (e.responseText) != "undefined") {
var response = $.parseJSON(e.responseText);
}
}
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return kendo.stringify({ models: options.models });
}
options.PersonId = 0;
if (viewModel.SelectedPreceptor != null) {
if (viewModel.SelectedPreceptor.PersonId != "" && viewModel.SelectedPreceptor.PersonId != null) {
options.PersonId = viewModel.SelectedPreceptor.PersonId;
}
}
return kendo.stringify(options);
}
},