PDA

View Full Version : CheckBox MenuItem AutoRef issue



parky128
27 Oct 2010, 5:57 AM
Hiya,

I have some designer generated toolbar UI like so:


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:


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

jarrednicholls
27 Oct 2010, 6:11 AM
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/showthread.php?99895-MenuItem-autoRef

Thanks,
Jarred