如何停止kendo网格/数据源自动将更改发布到服务器?
我已经尝试拦截Grid的saveChanges,但是它不是由Updated命令触发的。根据docs,默认情况下,DataSource的自动同步应该为false,但我还是继续进行了设置,但没有任何效果。
$("#items-grid").kendoGrid({
dataSource: {
autoSync: false,
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("
ItemList ", "
PurchaseRequisition ", new {prId = @Model.Id }))",
type: "POST",
dataType: "json",
},
update: {
url: "@Html.Raw(Url.Action("
ItemEdit ", "
PurchaseRequisition "))",
type: "POST",
dataType: "json",
}
},
sync: function(e) {
console.log("sync complete");
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
/...
}
}
},
},
saveChanges: function(e) {
// not fired from Update command
e.preventDefault();
},
columns: [{
// ...
}, {
command: [{
name: "edit",
text: {
edit: "Edit",
update: "Update",
cancel: "Cancel"
}
}],
width: 100
}]
});
});
您可以尝试将dataSource
批处理设置为true
。
var dataSource = new kendo.data.DataSource({
transport: {...},
batch: true
...}
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [...],
editable: true
});
NOTE:这是内联编辑。
您可以在官方页面上看到一个示例:Batch editing