1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    9
    Vote Rating
    0
    resTive is on a distinguished road

      0  

    Default MenuItem autoRef

    MenuItem autoRef


    Hi there,

    i try to add a handler to an MenuItem via its reference but it seems there is no reference added to the viewport? Am i missing something?

    here is my code:

    the viewport ui:
    Code:
    ViewportUi = Ext.extend(Ext.Viewport, {
      layout: 'border',
      initComponent: function() {
        this.items = [
          {
            xtype: 'panel',
            region: 'center',
            layout: 'card',
            activeItem: 0,
            ref: 'contentPanel',
            tbar: {
              xtype: 'toolbar',
              items: [
                {
                  xtype: 'button',
                  text: 'MyButton',
                  ref: '../../buttonRef',
                  menu: {
                    xtype: 'menu',
                    items: [
                      {
                        xtype: 'menuitem',
                        text: 'Menu Item',
                        ref: '../../../../menuItemRef'
                      }
                    ]
                  }
                }
              ]
            }
          }
        ];
        ViewportUi.superclass.initComponent.call(this);
      }
    });
    the viewport instance:
    Code:
    Viewport = Ext.extend(ViewportUi, {
      initComponent: function() {
        Viewport.superclass.initComponent.call(this);
        console.log(this.contentPanel);//works for the Panel
        console.log(this.buttonRef);//works for the Button
        console.log(this.menuItemRef);//doesnt work for the MenuItem
      }
    });
    thank you for your help

  2. #2
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    I believe this may be a bug or omission in ExtJS proper. I'm not able to get ref's to work for buttons inside of a menu that's tied to a button. I will put in a bug ticket for you.

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Posts
    9
    Vote Rating
    0
    resTive is on a distinguished road

      0  

    Default


    thank your for the quick information.
    is there a handy workaround, or there another 'easy' way to add an without using ids?

  4. #4
    Ext JS Premium Member
    Join Date
    Oct 2009
    Location
    Hamilton ON Canada
    Posts
    25
    Vote Rating
    0
    fargs is on a distinguished road

      0  

    Default


    I am having the same issue

  5. #5
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    I would resort to component ids as a for-sure workaround at this point. I am going to post a monkey-patch to Ext JS in a few minutes.

    EDIT:

    Here's a monkey patch that fixes the issue. I typically put these types of overrides in an ext-overrides.js file and include that just after I include Ext (i.e. ext-all.js).

    This code only works if the menu is configured as an xtype object (such as the above case), it won't help menus configured as an array of items. The Designer doesn't generate the latter...
    Code:
    Ext.Button.prototype.initComponent = Ext.Button.prototype.initComponent.createInterceptor(function(){
        if (this.menu){
            this.menu.ownerCt = this;
        }
    });

  6. #6
    Ext JS Premium Member
    Join Date
    Oct 2009
    Location
    Hamilton ON Canada
    Posts
    25
    Vote Rating
    0
    fargs is on a distinguished road

      0  

    Default


    Nice fix ... thanks!

  7. #7
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    388
    Vote Rating
    13
    devtig will become famous soon enough

      0  

    Default


    I believe this problem still exists with Ext JS 3.3.0 and the monkey fix still works.

  8. #8
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    putting in a permanent fix for 3.3.1

  9. #9
    Sencha User
    Join Date
    Aug 2009
    Posts
    75
    Vote Rating
    0
    madirishman is on a distinguished road

      0  

    Default


    Did the fix make it to the final release of 3.3.1? I just installed it and it still behaves the same.

  10. #10
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    It would appear not, I don't think it was merged. It'll be in 3.3.2 in that case. Sorry!

Similar Threads

  1. MenuItem Event
    By rizla in forum Ext GWT: Help & Discussion (1.x)
    Replies: 12
    Last Post: 10 Oct 2010, 2:28 AM
  2. Ref, autoRef, and name
    By firefoxSafari in forum Ext Designer: Help & Discussion
    Replies: 3
    Last Post: 19 Apr 2010, 4:32 PM
  3. Replies: 1
    Last Post: 15 Apr 2010, 10:09 AM
  4. Replies: 5
    Last Post: 21 Dec 2009, 2:25 AM
  5. can 2 menus use one menuItem
    By aj3423 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 19 May 2009, 12:24 AM

Thread Participants: 6