这里是我的网格:剑道格删除按钮不会触发删除功能
$("#category-gridview").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: function (options) {
return '/Product/GetCategories?id=' + $("#selectedProductId").val() + '&company=' + $("#company-dropdown").val() + '&language=' + $("#country-dropdown").val();
},
dataType: "json",
type: "POST"
},
destroy: {
url: '/Product/DeleteProductCategory',
dataType: "json",
type: "POST",
contentType: "application/json"
},
parameterMap: function (options, operation) {
console.log("HÄÄR");
console.log(options);
if (operation !== "read" && options.models) {
return JSON.stringify({
category: options
});
}
}
},
schema: {
model: {
fields: {
id: {
type: "string"
},
name: {
type: "string"
},
}
}
},
},
columns: [{
field: "id",
hidden: true
}, {
field: "name",
title: "Category",
width: "30px"
}, {
command: "destroy",
title: " ",
width: 15
}],
editable: false,
});
莫名其妙的读取功能工作正常,但是当我按下删除按钮我甚至不会达到我的参数映射功能。 当我在铬控制台看,没有请求发送到我的控制器。
这里是我的控制器方法:
[HttpPost]
public JsonResult DeleteProductCategory(CategoryResponse category)
{
return Json(category);
}
也许尝试移除类型:“JSON”(根据文档的HTTP ://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-type,这不是dataSource.type的有效设置) –
谢谢!但这并没有帮助:( –
哦,我认为你需要在参数映射函数中返回某些操作被销毁时的东西 –