剑道网格自定义编辑器如何发送元素?



好的,我有这个剑道

$("#configGrid").kendoGrid({
columns: [
{
title: "Index",
template: '<span>#: Index #</span>'
},
{
title: "Trigger Bet",
field: "TriggerBet",
editor: customEditor(e, 0.01, 2, 0 )
},
{
title: "Rounds Probability",
field: "RoundsProbability",
editor: customEditor(e, 10, 0, 0)
},
{
title: "Hot Odds",
field: "HotOdds",
editor: customEditor(e, 10, 0, 0)
},
{
title: "Seed amount",
field: "SeedAmount",
editor: customEditor(e, 10, 0, 0)
},
{
title: "Contribution",
field: "Contribution",
editor: customEditor(e, 0.01, 2, 0)
}
],
dataSource: {
data: getConfigDataFromModel().configs,
},
editable: true,
navigatable: true
});

正如你所看到的,我的几乎列都得到了这个customEditor我想将元素本身发送到这个函数的地方

function customEditor(e, steps, decimals, min) {
if (e.container.find("[name]").first().attr("name") == "HotOdds") {
console.log(e.model.JackpotType + "hello");
if (e.model.JackpotType === "Progressive jackpot") {
e.sender.closeCell();
}
}
GJP.createEditor(steps, decimals, min);
}

问题是它在这里没有定义,因为我从我的列发送的内容实际上并没有发送元素。有谁知道如何将元素正确发送到我的customEditor函数,以便它可以按预期处理它?一直在查看剑道文档,但我似乎找不到任何将元素作为参数发送到自定义编辑器的解决方案。

customEditor(e,0.01, 2, 0 ( 是一个函数调用而不是函数引用,这意味着它现在执行函数,就像在网格的初始化期间"e"还不存在(javascript 错误(,它不存在,直到当你单击单元格和 kendo调用函数时发生编辑事件, 提供"e"。

您需要使编辑器配置成为函数引用,而不是立即执行。 而且由于您还想将自己的参数附加到剑道提供的"e"上,因此您需要一个闭包。

所以

将您的编辑器配置定义为

...
editor: function (e) {
return customEditor(e, 0.01, 2, 0);
} 

例如:http://dojo.telerik.com/@Stephen/OcIxEGud

最新更新