这是我的 kendo ui 网格视图,它的读取功能触发得很好,但是当我想更新时问题才开始,我的控制器中的更新功能甚至没有触发,
<script>
$(document).ready(function () {
var dataSource = {
transport: {
type: "json",
read: {
url: "@Html.Raw(Url.Action("CommentList", "Comment"))",
type: "POST",
dataType: "json"
},
update: {
url: "@Html.Raw(Url.Action("CommentUpdate", "Comment"))",
type: "POST",
dataType: "json"
},
destroy: {
url: "@Html.Raw(Url.Action("CommentDelete", "Comment"))",
type: "POST",
dataType: "json"
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
Id: { type: "number" },
ProductName: { editable: false, type: "string"},
ProductPicture: { editable: false, type: "string"},
Text: { editable: false, type: "string"},
AdminConfirm: { editable: true, type: "boolean", validation: { required: true } }
}
}
},
requestEnd: function (e) {
if (e.type === "create" || e.type === "update") {
this.read();
}
},
error: function (e) {
alert("something wrong!");
// Cancel the changes
this.cancelChanges();
},
pageSize: 15,
serverPaging: true,
serverFiltering: true,
serverSorting: true
};
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: {
refresh: true,
pageSizes: [10, 15, 20, 30, 50]
},
height: 550,
columns: [
{
field: "ProductName",
title: "product name",
width: "90px"
},
{
field: "ProductPicture",
title: "picture",
width: "100px",
},
{
field: "Text",
title: "comment",
width: "180px"
},
{
field: "AdminConfirm",
title: "adminconfirm",
width: "70px",
},
{
command: [
{
name: "edit" , text: { // sets the text of the "Edit", "Update" and "Cancel" buttons
edit: "edit",
update: "update",
cancel: "cancel"
}
}
],
title: " ", width: "250px"
}
],
editable : {
mode : "popup",
window : {
title: "confirmation form"
}}
});
});
</script>
</div>
这是我的第一行更新函数
[HttpPost]
public ActionResult CommentUpdate(DataSourceRequest request, CommentViewModel comment)
有人知道为什么吗?提前感谢