本文介绍了extjs 树面板上下文菜单不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var menu1 = new Ext.menu.Menu({
    items: [{
        text: 'Open in new tab'

    }]
});
var treePanel = Ext.create('Ext.tree.Panel', {
    id: 'tree-panel',
    region: 'center',
    useArrows: true,
    singleExpand: true,
    split: false,
    height: 360,
    minSize: 150,
    rootVisible: false,
    autoScroll: true,
    store: store,
    border: false,
    columns: [{
        xtype: 'treecolumn',
        dataIndex: 'text',
        flex: 2,
        sortable: true,
        displayField: true
    }]

});
treePanel.on('contextmenu', function(event, node) {
    alert(node)
    //treePanelCurrentNode = node;
    x = event.browserEvent.clientX;
    y = event.browserEvent.clientY;
    menu1.showAt([x, y]);
}, this);

正在处理 4.1 ext js 并尝试将上下文菜单添加到此树面板,但菜单不起作用.在树面板商店来了但我的代码

Working on 4.1 ext js and trying to add context menu to this tree panel but menu is not working. In the tree panel store is comingbut my code

treePanel.on('contextmenu', function(event,node){};

不工作不是事件

treePanel.on('click', function(event,node){};

任何与树面板上的 ext js 上下文菜单相关的想法?

Any idea related to ext js context menu on tree panel ?

推荐答案

Tree 在 ExtJS4 中没有 contextmenu 事件.

Tree doesn't have contextmenu event in ExtJS4.

你应该使用 itemcontextmenu 而不是 contextmenu:

treePanel.on('itemcontextmenu', function(view, record, item, index, event) {
    alert(record)
    //treePanelCurrentNode = record;
    menu1.showAt(event.getXY());
    event.stopEvent();
}, this);

这篇关于extjs 树面板上下文菜单不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 20:28