2012-04-18 53 views
3

上下文菜单我有上下文菜单像我怎么能创造ExtJS的面板

var ctxMenu = Ext.create('Ext.menu.Menu', { 
    items: [{ text: 'Edit', action: 'edit'}] 
}); 

我这怎么能添加到ExtJS的面板?我没有在面板中看到任何合适的事件,例如在resinpanel中的itemcontextmenu

高级谢谢。

回答

4

Ext.tree.Panelitemcontextmenucontainercontextmenu事件。

更新:Ext.grid.Panel存在相同的事件。你可能想订阅的两个人身上,做这样的事情:

showContextMenu: function(e) { 
    var me = this; 

    if (me.contextMenu === undefined) 
     return; 

    e.stopEvent(); 
    me.contextMenu.showAt(e.getXY()); 
}, 

// Show context menu from the grid 
gridContextMenu: function(view, rec, node, index, e) { 
    this.showContextMenu(e); 
}, 

// Show context menu from the empty area below grid records 
containerContextMenu: function(view, e) { 
    this.showContextMenu(e); 
}, 
+0

其实我需要添加上下文菜单中Ext.panel.Panel(的xtype:面板) – Jom 2012-04-19 07:28:12

+0

同样的事情。它在那里。你只需要适当地呈现它。查找菜单文档 – sha 2012-04-19 10:12:56

+0

检查更新的答案。我发布了一些示例代码。 – sha 2012-04-19 12:32:41