Handsontable 自定义菜单 自定义命令存放位置

默认是 右键 弹出菜单。

项目需要改为 统一放置到头部。

以 右对齐为例

    var hot1 = new Handsontable(ele, ...);

    window.plugin = hot1.getPlugin('contextMenu');

    $('#alignmentRight').click(function(){
        // plugin.executeCommand('undo');
        
        plugin.executeCommand('alignment:right');
    });

此时点击 #alignmentRight 内容, 页面会报错:


Cannot read property 'from' of undefined


但是如果 执行的是 上面 注释掉的 “undo” 命令, 则是可以执行的。

如果在页面中 , 选好选区以后 ,直接在console面板 ,输入

plugin.executeCommand('alignment:center');

也是可以执行的。

说明是 当我们点击 自定义按钮时, 选区对象被清掉了, 所以 在执行 command时, 会缺少一些选区参数。

posted @ 2017-03-03 16:41  tuziguaiguai  阅读(2064)  评论(0编辑  收藏  举报