I'm trying to get the component in which a menu is linked. Take a look:
Ext.create('Ext.Button', {
id: 'MyButton',
text: 'Click me',
renderTo: Ext.getBody(),
menuAlign: 'tl-bl',
menu: {
itemId: 'MyMenu',
forceLayout: true,
items:
[
{
text : 'Option 1',
itemId: 'MyItemMenu1'
}, {
text : 'Option 2',
itemId: 'MyItemMenu2'
}, {
text : 'Get the parent!',
itemId : 'MyItemMenu3',
handler: function(){
// Get the item menu.
var MyItemMenu3 = this;
alert(MyItemMenu3.getItemId());
// Get the menu.
var MyMenu = MyItemMenu3.ownerCt;
alert(MyMenu.getItemId());
// Try to get the button.
var MyButton = MyMenu.ownerCt;
alert(MyButton);
// Returns:
// 'MyItemMenu3'
// 'MyMenu'
// undefined
}
}
]
}
});
Online example: http://jsfiddle.net/RobertoSchuster/mGLVF/
Any idea?
I'm learning EXT myself so I'm not too sure what's going on but I think I was able to get it this way: console.log(MyMenu.floatParent.id)
;