我从服务器返回错误并在kendo datasource错误事件中捕获它。在这个事件中我试图阻止关闭弹出编辑器,但它只能第一次工作,在第二次点击更新后,窗口一直关闭
这是一些代码;
dataSource = new kendo.data.DataSource({
transport: {
create: function (e) {
// just posting server with ajax
InsertCity("/city/insert", e.data, function (res) {
var grid = $("#gCity").data("kendoGrid");
if (res.success) {
grid.dataSource.data(res.data);
} else {
e.error("", "", res.error);
grid.cancelChanges();
}
})
},
error: function (e) {
// after throwing error in transport/create, it comes here
var grid = $("#gCity").data("kendoGrid");
grid.one("dataBinding", function (e) {
e.preventDefault();
});
alert(e.errorThrown);
},
pageSize: 20,
schema: {
model: {
id: "ID",
fields: {
Name: { type: "string" }/*,
EndDate: { type: "date" },
CreateDate: { type: "date" }*/
}
}
}
});
$("#gCity").kendoGrid({
dataSource: dataSource,
height: 550,
selectable: "single",
filterable: true,
sortable: true,
pageable: true,
toolbar: [{ name: "new", text: "New" }],
columns: [{ field: "Name", title: "Name" }],
editable: {
mode: "popup",
confirmation: false,
template: kendo.template($("#popup_editor").html())
}
});
我搜索了很多但找不到解决方案
答案 0 :(得分:0)
尝试添加此内容:
var onWindowEditClose = function (e) {
debugger;
if (preventCloseOnSave) {
e.preventDefault();
preventCloseOnSave = false;
}
};
我从here那里得到了