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

Kendo grid custom editor how to send the element?

好的,我有这个 kendo网格

$("#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 文档,但我似乎找不到任何将元素作为参数发送到自定义编辑器的解决方案。

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

您需要让您的编辑器配置为函数引用,而不是立即执行。由于您还想将自己的参数添加到 kendo 提供的 "e" 中,因此您需要一个闭包。

所以,

将您的编辑器配置定义为

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

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