mardi 2 juillet 2019

Editor Error - No such editor found: dateEditor in tabulator code

I am using tabulator code in ember js, to build editable table. Here I need a formatter for date(http://tabulator.info/examples/4.2 -- Editable data), as per the example given in tabulator api I have tried, here I am getting Editor Error - No such editor found: dateEditor.

I am assigning the dateEditor for the column as below at run time. I have tried like below this also editor: "dateEditor(cell, onRendered, success, cancel)" getting same error.

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;
};

Could some please help me how to call customEditor in tabulator code.




Aucun commentaire:

Enregistrer un commentaire