我在剑道网格的一列中定义了一个销毁命令:
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"
}
]
可编辑设置为网格的内联。数据源的 Batch 设置为 true。
编辑和保存工作正常(所有模型都以 JSON 格式发送到 SAVE 方法)。
但是,当我为其中一行单击删除时,它会从网格中删除该行,但它的行为就像我保存所有项目一样。它调用 save 方法并在 JSON 对象中发送每一行,除了我要删除的那一行。
问题是:为什么不调用destroy方法?
它不应该调用destroy方法并只发送被删除的行吗?
数据源定义:
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);
}
},