2012-04-18 51 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