extjs 树面板上下文菜单不起作用

发布于 2024-12-10 11:19:28 字数 1019 浏览 0 评论 0原文

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 并尝试将上下文菜单添加到此树面板,但菜单不起作用。树面板商店即将到来 但我的代码

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

不起作用 不是事件

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

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

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);

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 coming
but my code

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

is not working
not event

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伊面 2024-12-17 11:19:28

Tree 在 ExtJS4 中没有 contextmenu 事件。

您应该使用 itemcontextmenu 而不是 contextmenu

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

Tree doesn't have contextmenu event in ExtJS4.

You should use itemcontextmenu instead of contextmenu:

treePanel.on('itemcontextmenu', function(view, record, item, index, event) {
    alert(record)
    //treePanelCurrentNode = record;
    menu1.showAt(event.getXY());
    event.stopEvent();
}, this);
居里长安 2024-12-17 11:19:28

当数据视图呈现时,它会禁用默认的右键单击 Web 浏览器菜单,这在侦听器“render”事件中调用,“itemcontexmenu”事件用于检测鼠标右键事件,捕获鼠标光标位置并显示菜单。

  listeners: {


        render: function() {
             Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
        },
        itemcontextmenu : function( grid, record, item, index, event){
            x = event.browserEvent.clientX;
            y = event.browserEvent.clientY;

            menu1.showAt([x, y]);


        }
}

When the data view is rendered it disabling the default right click web browser menu, this is called in listeners “render” event and “itemcontexmenu” event is for detecting right click mouse event, capture the mouse cursor position and displaying the menu.

  listeners: {


        render: function() {
             Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
        },
        itemcontextmenu : function( grid, record, item, index, event){
            x = event.browserEvent.clientX;
            y = event.browserEvent.clientY;

            menu1.showAt([x, y]);


        }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文