View Full Version : TreePanel Context menu question (el is undefined)

21 Feb 2010, 9:46 PM
I am porting from Ext2.x to Ext3.1.
I have a tree panel with context menu. In 3.1+, I get an error:

menu.getEl() is undefined in this line of code:
//node is the tree node
menu.showAt(menu.getEl().getAlignToXY(node.getUI().getTextEl(), 'tl-bl?',[40,0]));
I changed this to:

This got me past the undefined error, but now I get the error:

el is undefined
[Break on this error]
out = (v = el.style[prop]) ? v : ext-all-debug.js (line 5773)

Whenever the context menu is displayed.

Could anyone provide some help on why menu.getEl() is undefined in the first place?


21 Feb 2010, 11:23 PM
On a gridpanel...

var myMenu = new Ext.menu.Menu({id: 'myMenu',items: [{xtype:'label',id:'myMenuLabel',text:'this is the context menu'}]});

gp_lopdata.addListener('cellcontextmenu',function(grid, row, col, e)

21 Feb 2010, 11:51 PM
Well the Menu isn't rendered before it's first shown is it? So there's no el.

22 Feb 2010, 8:49 AM
el is undefined because it has not been rendered yet. Alright.

What is the correct way to render a context menu with some [x,y] offset?
In the initial config for the Menu - I set:
defaultOffsets: [30,0]
and in the 'contextmenu' handler do:

menu.show(node.ui.getAnchor()); //menu is the context menu, node is the treenode

Now I get el is undefined in ext-all-debug.js
out = (v = el.style[prop]) ? v : ext-all-debug.js (line 5773)

What am I doing wrong?

1 Dec 2011, 7:38 AM
Hi, I have the same problem
I don't see what means animal when he say that the

Menu isn't rendered before it's first shown is it? So there's no el.

normaly you instanciate a menu this way

var menu = new Ext.menu.Menu({
id: 'menuId',
{ id: 'item1Id',
handler: function() {



and when you want to make the menu appear you do the following

menu.show(node.ui.getAnchor()); (if I want to positionnate at a tree node level)

There is no question about rendering ? I don' see what he means

And when you add a sub menu on items of the menu, what have you to do to avoid this error ?