【发布时间】:2011-10-17 18:43:00
【问题描述】:
我正在尝试获取链接菜单的组件。 看看:
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
}
}
]
}
});
在线示例: http://jsfiddle.net/RobertoSchuster/mGLVF/
有什么想法吗?
【问题讨论】:
-
我自己正在学习 EXT,所以我不太确定发生了什么,但我认为我能够通过这种方式获得它:console.log(MyMenu.floatParent.id);
-
完美!有用!谢谢。
-
好的,我会把它作为答案提交 :) 很高兴它对你有用!