Results 1 to 5 of 5

Thread: TreePanel Context menu question (el is undefined)

  1. #1

    Default TreePanel Context menu question (el is undefined)

    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:
    menu.show(node.getUI().getAnchor());

    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?

    Thanks.

  2. #2

    Join Date
    Jun 2008
    Location
    Belgium
    Posts
    265

    Default

    On a gridpanel...

    Code:
    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)
    {
    myMenu.showAt(e.getXY());
    Ext.getCmp('myMenuLabel').setText('('+row+','+col+')');
    e.stopEvent();
    });

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

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

  4. #4

    Default

    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?

  5. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default

    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',
    items:[
    { 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 ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •