extjs tree panel context menu not working

前端 未结 2 2300
说谎
说谎 2021-02-20 05:06
var menu1 = new Ext.menu.Menu({
    items: [{
        text: \'Open in new tab\'

    }]
});
var treePanel = Ext.create(\'Ext.tree.Panel\', {
    id: \'tree-panel\',
             


        
2条回答
  •  臣服心动
    2021-02-20 05:24

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

提交回复
热议问题