PDA

View Full Version : How to set menuitem.menu width to fit text



iamcootis
30 Jul 2013, 8:52 AM
I have a menu that has menuItems with submenus. The initial problem was that the label for the submenu was truncated because of the width. Then I set the menuItem.menu.width = '100%'. Unfortunately, this expanded to the entirety of the screen and not the width of the label.

What do I need to do to set a menuItem.menus width to fit its label?



createSubmenu: function(menuLabel,submenus){

var anItem = {};
anItem.menuitem = submenus;


var aMenu = this.createMenu(anItem);


var aSubMenu = Ext.create('Ext.menu.Item',{
text: menuLabel,
menu: aMenu
});
aSubMenu.menu.width = '100%';


return aSubMenu;
}

slemmon
4 Aug 2013, 10:42 PM
Is it an issue you're seeing in 4.2.1? I wasn't able to create a standalone test case reproducing the issue:



Ext.create('Ext.menu.Menu', {
width: 150,
margin: '0 0 10 0',
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
text: 'regular item 1',
menu: {
items: [{
text: 'A submenu with very long menu item text'
}]
}
},{
text: 'regular item 2'
},{
text: 'regular item 3'
}]
});

iamcootis
5 Aug 2013, 4:42 AM
We're using 4.1

slemmon
6 Aug 2013, 1:34 PM
I tried the attached test case with 4.2.1 and 4.1.0 and in both instances it appeared to render correctly. Are you not seeing the same thing with the given test case? Do you have an alternative test case you can post?