【问题标题】:Editor Error - No such editor found: dateEditor in tabulator code编辑器错误 - 未找到此类编辑器:制表符代码中的 dateEditor
【发布时间】:2019-07-02 18:26:45
【问题描述】:

我在 ember js 中使用制表符代码来构建可编辑的表格。 在这里我需要一个日期格式化程序(http://tabulator.info/examples/4.2 -- 可编辑数据),根据我尝试过的制表器 api 中给出的示例,这里我收到编辑器错误 - 找不到这样的编辑器:dateEditor。

我在运行时为列分配日期编辑器,如下所示。 我也尝试过像下面这样的编辑器:“dateEditor(cell, onRendered, success, cancel)” 得到同样的错误。

columnMap = 
{ 
align: "center", editor: "dateEditor"
}

var dateEditor = function(cell, onRendered, success, cancel){
    //cell - the cell component for the editable cell
    //onRendered - function to call when the editor has been rendered
    //success - function to call to pass the successfuly updated value to Tabulator
    //cancel - function to call to abort the edit and return to a normal cell

    //create and style input
    var cellValue = moment(cell.getValue(), "DD/MM/YYYY").format("YYYY-MM-DD"),
    input = document.createElement("input");

    input.setAttribute("type", "date");

    input.style.padding = "4px";
    input.style.width = "100%";
    input.style.boxSizing = "border-box";

    input.value = cellValue;

    onRendered(function(){
        input.focus();
        input.style.height = "100%";
    });

    function onChange(){
        if(input.value != cellValue){
            success(moment(input.value, "YYYY-MM-DD").format("DD/MM/YYYY"));
        }else{
            cancel();
        }
    }

    //submit new value on blur or change
    input.addEventListener("blur", onChange);

    //submit new value on enter
    input.addEventListener("keydown", function(e){
        if(e.keyCode == 13){
            onChange();
        }

        if(e.keyCode == 27){
            cancel();
        }
    });

    return input;
};

请帮助我如何在制表符代码中调用 customEditor。

【问题讨论】:

    标签: javascript ember.js tabulator


    【解决方案1】:

    根据文档,自定义编辑器使用其变量或函数名称直接分配。不是字符串。

    columnMap = 
    { 
    align: "center", editor: dateEditor
    }
    

    您的代码顺序也有误。您不能分配尚不存在的东西。先定义编辑器,再赋值给column map,再构造表。

    【讨论】:

    • 它正在工作,非常感谢,非常感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多