【问题标题】:Tabulator tables context click event needed before editor编辑器之前需要的制表符表上下文单击事件
【发布时间】:2020-07-26 07:07:48
【问题描述】:

我对 Tabulator 比较熟悉,但是客户要求我在右键单击单元格以调出菜单时以及左键单击要编辑的单元格时要求我这样做。 在编辑器启动之前,我无法抓住鼠标左键或右键事件。

我在这里阅读了我认为正确的技术:https://github.com/olifolkerd/tabulator/issues/1242 但似乎 'contextClick' 事件不再存在。

在文档中,存在以下事件,我无法在以下代码中的编辑器、自定义或“数字”之前触发它们中的任何一个:

{
    columns:[
        {title:"u2",        field:"u2",         editor:"number",    editable:true},
    ],
    cellClick:function(e, cell){    
        console.log('cell left');
        e.stopImmediatePropagation();
    },
    cellContext:function(e, cell){
        console.log('cell right');
        e.stopImmediatePropagation();
    },
    rowContext:function(e, cell){
        console.log('row right');
        e.stopImmediatePropagation();
    },
    contextClick:function(e, cell){
        console.log('context click');
        e.stopImmediatePropagation();
    },
}

右键单击时,输出为“单元格正确”,但编辑器,“数字”或自定义编辑器会预先触发。 我确认自定义编辑器没有区别,自定义编辑器在“单元格右侧”被记录之前被触发。

【问题讨论】:

    标签: javascript tabulator


    【解决方案1】:

    导致编辑的上下文单击是一个错误,已在 Tabulator 4.8 版本中解决。

    如果您喜欢更简单的设置,Tabulator 还具有自己的内置上下文菜单功能。

    您可以使用列定义中的 contextMenu 选项设置上下文菜单:

    //define row context menu
    var cellContextMenu = [
        {
            label:"Reset Value",
            action:function(e, cell){
                cell.setValue("");
            }
        },
    ]
    
    //add header menu in column definition
    var table = new Tabulator("#example-table", {
        columns:[
            {title:"Name", field:"name", width:200, contextMenu:cellContextMenu}, //add a context menu to the cells in this column
        ]
    });
    

    查看Menu Documentation了解更多详情

    【讨论】:

      猜你喜欢
      • 2013-07-05
      • 1970-01-01
      • 2022-10-15
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多