PDA

View Full Version : dynamic menu with click event



zlevardy
8 Jan 2014, 6:33 AM
hi,

I am trying to add a menu on the fly to a toolbar, what toolbar also made runtime. The problem is unable to add click event to that menu item. I have tried using Controller:


this.control({ 'cWwMenu > menuitem': { click: this.onWwMenuClick } }

...

onWwMenuClick: function(menuitem) { //THIS NOT HAPPENS!!! }


where menu is from my panel (view):


var top5tb = Ext.create('Ext.toolbar.Toolbar', {
itemId: 'top5tb',
width: '100%',
items: [
{
xtype: 'splitbutton',
text: 'Worldwide',
itemId: 'cWwSb',
tooltip: 'Ch region',
arrowAlign: 'right',
menu:
{
xtype: 'menu',
itemId: 'cWwMenu',
beforeshow: 'assertMenuHeight',
items: []
}
...


});

//find available countries:
var st = Ext.StoreMgr.get('Country');
st.load({
callback: function(records, operation, success) {


st.each( function(item, index, totalItems ) {
top5tb.down('#cWwMenu').add( item.get('name') );
});
}
});



is this concept good at all? any idea what went wrong?

thanks a lot,
Zol