1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    410
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default CheckBox MenuItem AutoRef issue

    CheckBox MenuItem AutoRef issue


    Hiya,

    I have some designer generated toolbar UI like so:

    Code:
    Ext.ns('SBS.Websites.PP3');
    SBS.Websites.PP3.MapPanelToolbarUi = Ext.extend(Ext.Toolbar, {
        initComponent: function() {
            this.items = [
                {
                    xtype: 'button',
                    text: 'Find a Location'
                },
                {
                    xtype: 'button',
                    text: 'Find Nearest Unit'
                },
                {
                    xtype: 'tbseparator'
                },
                {
                    xtype: 'button',
                    text: 'Reset Map',
                    ref: 'btnResetMap'
                },
                {
                    xtype: 'tbfill'
                },
                {
                    xtype: 'splitbutton',
                    text: 'Map Options',
                    menu: {
                        xtype: 'menu',
                        items: [
                            {
                                xtype: 'menucheckitem',
                                text: 'Show Traffic',
                                ref: '../../checkShowTraffic'
                            }
                        ]
                    }
                }
            ];
            SBS.Websites.PP3.MapPanelToolbarUi.superclass.initComponent.call(this);
        }
    });
    And in my own js file I am now trying to reference the toolbar items by their ref values so I can hook up some event handlers:

    Code:
    initComponent: function() {
            var config={};
            Ext.apply(this, config);
            Ext.apply(this.initialConfig, config);
            
            SBS.Websites.PP3.MapPanelToolbar.superclass.initComponent.call(this);
            
            // Find the top element (should be the viewport) and use it to set appHub
            var topEl=this;
            while(topEl.ownerCt!==undefined) { topEl=topEl.ownerCt; }
            this.appHub=topEl.appHub;
            
            //Toolbar button listeners...
            this.btnResetMap.on('click', this.ResetMap, this);
            
            //doesnt work...
            this.checkShowTraffic.on('click', this.ShowTraffic, this);
        }
    But I am unable to get a reference to the Show Traffic menucheckitem I have in my UI code by looking up via the ref property. Am I better off just giving it ID and grabbing it that way?

    Can someone please assist?

    Thanks,
    Rob

  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


    Hey Rob,

    Right you are. ref's don't work on items inside of a menu that's attached to a button. It's been a bug that was, regretfully, not resolved for Ext 3.3. I have posted a monkey patch awhile back, which still works. You can grab it from here: http://www.sencha.com/forum/showthre...nuItem-autoRef

    Thanks,
    Jarred

Similar Threads

  1. MenuItem autoRef
    By resTive in forum Ext Designer: Help & Discussion
    Replies: 15
    Last Post: 24 May 2011, 11:06 AM
  2. Menuitem Checkbox
    By mihaip007 in forum Ext Designer: Help & Discussion
    Replies: 3
    Last Post: 30 Aug 2010, 9:20 PM
  3. Ref, autoRef, and name
    By firefoxSafari in forum Ext Designer: Help & Discussion
    Replies: 3
    Last Post: 19 Apr 2010, 4:32 PM
  4. Replies: 5
    Last Post: 21 Dec 2009, 2:25 AM

Thread Participants: 1