PDA

View Full Version : help with Toolbar and Ext.menu.Menu



xxhalfpint
28 Jun 2012, 9:32 AM
I understand that when using toolbar you can use the menu config to set up your menuitems
Example:

xtype: 'toolbar',
items: [{
text:'button',
menu: (in here goes all your items)
}]

I'm using the menu in multiple places in my project and would like to create my own menu class. I'm struggling with figuring out how to do this. I was thinking something like.

xtype: 'toolbar',
items: [{
text:'button',
menu: (with my alias for the menu here)
}]

Is something like this possible?

scottmartin
28 Jun 2012, 12:17 PM
You can use:



Ext.define('My.app.Menu' ,{
alias: 'widget.mymenu', // xtype: 'mymenu'
...
});

Then you can call as needed.

Scott.

xxhalfpint
28 Jun 2012, 1:13 PM
so I did as you suggested.

My code looks as follows:


...
xtype:'toolbar',
items: [{
text:'Actions',
menu: 'foldermenu'
}]
...


Ext.define('My.app.Menu' , {
extend: 'Ext.menu.Menu',
alias: 'widget.foldermenu', // xtype: 'foldermenu'
...
});


I'm getting a me.menu is undefined. I feel as though menu: (with the xtype) is the problem but haven't found a solution for this yet.

xxhalfpint
28 Jun 2012, 1:26 PM
Fix




...
xtype:'toolbar',
items: [{
text:'Actions',
menu: {xtype:'foldermenu'}
}]
...

Ext.define('My.app.Menu' , {
extend: 'Ext.menu.Menu',
alias: 'widget.foldermenu', // xtype: 'foldermenu'
...
});


Thanks for the help Scott!