【问题标题】:Double editable callbacks双重可编辑回调
【发布时间】:2021-02-24 18:10:00
【问题描述】:

制表符 4.9.3

我有一个表,其中有一列的 editable 回调定义如下:

{ field: "name", title: "Name", editor:"input", editable:function(cell){
        return confirm( "Are you *SURE* you want to edit the name?" );
    }
},

如果我点击单元格,确认对话框会被触发两次。这是预期的吗? (对话框打开,我点击取消,对话框再次打开,点击取消,对话框消失)

【问题讨论】:

    标签: tabulator


    【解决方案1】:

    问题似乎是在较新版本的 Electron 中,在鼠标按下和鼠标按下时都会调用可编辑函数(我在 15 中遇到过这个问题)。

    幸运的是,您可以使用built-in callbacks 来检查鼠标指针是否在单元格上:

    cellMouseEnter: function (e, cell) {window.is_mouse_on_cell = true;},
    cellMouseLeave: function (e, cell) {window.is_mouse_on_cell = false;}
    

    然后在调用可编辑函数之前进行检查:

    editable: function (cell) {
        if (window.is_mouse_on_cell) {
            return confirm( "Are you *SURE* you want to edit the name?" );
        } else {
            return false;
        }
    

    我认为作者正在积极开发 Tabulator 的下一个主要版本,因此这不太可能在 4.9 中修复。

    此外,虽然 Electron 实施了警报和确认,但它们是阻塞的。如果遇到卡顿(可以通过此处的双重调用触发),请尝试dialog

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 2016-06-20
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 2013-10-18
      相关资源
      最近更新 更多