PDA

View Full Version : "up" function not working for button menu?



christophercheng
12 Nov 2011, 1:26 AM
I found out that submenu button inside a toolbar cannot reference to anything up to menu."this.up("menu")" is working, but "this.up("myGridPanel)" is not


Ext.define('MyCompany.MyApp.MyGridPanel',{
extend:'Ext.grid.Panel',
alias: 'widget.myGridPanel',
tbar: [
'-',
{
text: 'Add',
icon: 'image/icons/add.png',
listeners: {
click: function(btn, e, options) {
}
},
menu: {
xtype: 'menu',
items: [
{
text: "Postal Address",
listeners: {
click: function() {
this.up("menu"); // this is working
this.up("myGridPanel); // this is NOT working
}
}
},
{
]
}
}
],
store: Ext.create('MyCompany.MyApp.ContactMechStore', {
autoLoad: false,
proxy: {
type: 'ajax',
url : '/accounting/partyContactMech!list.action',
reader: {
type: 'json',
root: 'data',
idProperty: 'partyContactMechId'
}
}
}),
columns: [
{ header: 'column1', dataIndex: 'column1', hidden: true },
{ header: 'column2', dataIndex: 'column2' },
]

});

mitchellsimoens
12 Nov 2011, 7:36 AM
You have to use up() to get to the menu, then use the floatParent property to get to the grid... I'm not sure if the floatParent will point towards the grid or the toolbar.

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.menu.Menu-property-floatParent

skirtle
12 Nov 2011, 10:59 PM
The menu's floatParent is the button.

@mitchellsimoens. Do you not think it would be better if the up() method did this for us? Other parts of CQ use ownerCt or floatParent depending on which is available.

christophercheng
14 Nov 2011, 7:44 AM
confirmed that "this.up('menu').floatParent.up('gridpanel')" is working
thanks