我有一个可以创建/删除的剑道网格,它们都以错误结尾。我想:。
- 当删除错误以防止从网格中删除行时(这是出现错误时的默认行为)
- 当出现创建错误以防止弹出编辑器关闭时
请看这个小提琴:http: //jsfiddle.net/andreigavrila/p49eV/2/
var data = [
{ Id: 1, Name: "Decision 1", Code: 1 },
{ Id: 2, Name: "Decision 2", Code: 2 },
{ Id: 3, Name: "Decision 3", Code: 3 }
];
$("#grid").kendoGrid({
dataSource: {
error: function (a) {
console.log('error');
$('#grid').data("kendoGrid").cancelChanges();
//$('#grid').data("kendoGrid").one("dataBinding", function (e) {
//e.preventDefault(); // cancel grid rebind
//});
},
transport: {
read: function(e) {
e.success({data: data});
},
create: function(e) {
console.log('creating');
e.error();
},
destroy: function(e) {
console.log('deleting')
e.error();
}
},
schema: {
data: "data",
model: {
id: "Id",
fields: {
Id: { type: "number" },
Code: { type: "number" },
Name: { type: "string" }
}
}
}
},
toolbar: ["create"],
columns: [
{ field: "Code", title: "Code", },
{ field: "Name", title: "Name" },
{ command: ["destroy"], title: " " }],
editable: {
mode: "popup"
}
});
第二点默认有效(因此在创建时出错不会关闭弹出窗口)
第一点通过添加错误函数起作用,但这会破坏弹出窗口(它会在错误时关闭)。
所以我可以拥有我的任何一个,但不能同时拥有两个。我有点卡住了。我还在剑道论坛上看到了这两个问题:
第二个链接说“要防止 Grid 关闭,您需要防止下一个 dataBinding 事件。” 但我做不到。
谢谢您的帮助。
安德烈