问题描述
我遇到一个奇怪的问题:方法“ cell.edit()”不起作用(错误“未捕获的TypeError:e.column.modules.edit未定义” ),但是在同时所有其他方法都可以正常工作(例如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"},],});
谢谢。
解决方法
您的列上没有定义编辑器,因此无法对其进行调用编辑。此外,双击事件中没有点调用编辑,它将作为标准触发单击。
因此yuo会在列定义中查看以下内容:
{title:"Имя",field:"name",editor:"input"},