好的,我有这个剑道
$("#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函数以便它能够按预期处理它吗?一直在查看kendo文档,但我似乎找不到任何将元素作为参数发送给自定义编辑器的解决方案。
发布于 2018-09-26 13:54:25
customEditor(e,0.01,2,0)是一个函数调用而不是函数引用,这意味着它现在执行函数,就像在网格的init中,"e“还不存在(javascript错误),直到单击单元格和kendo调用函数时发生编辑事件时才存在它,并提供了"e”。
您需要使编辑器配置成为函数引用,而不是立即执行。而且,由于您还希望将您自己的参数修改为kendo提供的"e“,所以您需要一个闭包。
所以,
将编辑器配置定义为
...
editor: function (e) {
return customEditor(e, 0.01, 2, 0);
} 示例:http://dojo.telerik.com/@Stephen/OcIxEGud
https://stackoverflow.com/questions/52517200
复制相似问题