首页 > 解决方案 > cell.edit 不起作用(制表符 Node.js)

问题描述

我遇到了一个奇怪的问题:方法 "cell.edit()" 不起作用(错误"Uncaught TypeError: e.column.modules.edit is undefined"),但是同时所有其他方法都可以正常工作(例如 cell .getField();cell.getValue())。为什么会发生这种情况?

我的代码:

var table = new Tabulator("#grid1", {
        data:dannyje_iz_json, //assign data to table
        layout:"fitColumns", //fit columns to width of table (optional)
        rowContextMenu: rowMenu, //add context menu to rows
        columns:[ //Define Table Columns
            {title:"ID", field:"id"},
            {title:"Имя", field:"name", cellDblClick:function(e, cell){
                cell.edit(true); //works fine if change this to alert(cell.getField()); alert(cell.getValue());
                //now it leads to the error Uncaught TypeError: e.column.modules.edit is undefined
            }},
            {title:"Возраст", field:"age"},
        ],
    });

提前致谢。

标签: javascripttabulator

解决方案


您的列上没有定义编辑器,因此无法对其调用编辑。在双击事件中也没有必要调用编辑,它会按标准在单击时触发。

所以 yuo 会为列定义查看类似这样的内容:

{title:"Имя", field:"name", editor:"input"},

推荐阅读