PDA

View Full Version : [FIXED-116][3.0.0] ownerCt of Toolbar overflow menu not set



g2mac
9 Aug 2009, 2:16 AM
Hi!
There is a problem with my GridPanel. I have a buttons in toptoolbar and when I make gridpanel narrow my buttons hide in Ext.menu.Menu (created automatically). So, how can I get a reference to gridpanel inside buttons handlers? btn.findParentByType('grid') don't work ((
Please, help!

Animal
9 Aug 2009, 3:34 AM
Are you using extend to configure to create your grid?

g2mac
9 Aug 2009, 7:33 AM
No,
Grid = new Ext.grid.GridPanel(gridCfg);

Animal
9 Aug 2009, 7:48 AM
findParent should work then.

Use ext-all-debug.js, step in and find out WTF is happening.

Condor
10 Aug 2009, 3:37 AM
I actually think this is a bug: You can't find the owner panel from a toolbar overflow menuitem.

I would suggest something like:

Ext.override(Ext.layout.ToolbarLayout, {
initMore : function(){
if(!this.more){
this.moreMenu = new Ext.menu.Menu({
listeners: {
beforeshow: this.beforeMoreShow,
scope: this
}
});
this.moreMenu.ownerCt = this.container.ownerCt;
this.more = new Ext.Button({
iconCls: 'x-toolbar-more-icon',
cls: 'x-toolbar-more',
menu: this.moreMenu
});
var td = this.insertCell(this.more, this.extrasTr, 100);
this.more.render(td);
}
}
});

I would have preferred:

this.moreMenu.ownerCt = this.container;
but this would break handlers like:

handler: function(){
var panel = this.ownerCt.ownerCt;
...
}

(moving this to bugs)

Animal
10 Aug 2009, 3:41 AM
Ah! Yes. Does it get "detached" when moved into an overflow?

g2mac
11 Aug 2009, 1:44 AM
Condor, yeah, that's it!
Thanks!!!

evant
11 Aug 2009, 2:16 PM
I agree with the concept, though the override isn't correct. An overflowed toolbar can exist independently, so in that case your override would return undefined.

I'd be happier setting it to this.container, then if you wanted to retrieve the panel you'd use:



var p = menu.ownerCt.ownerCt;

evant
12 Aug 2009, 3:44 AM
Fixed in SVN r5038.

cginzel
17 Sep 2009, 8:39 AM
I have a menu toolbar button and using findParentByType within the menu item handler doesn't seem to find the "grandfather" grid. If I debug, I only see it go back as far as the parent menu.

cginzel
18 Sep 2009, 7:31 AM
I just downed the latest Ext 3 from SVN and I'm still seeing the same problem where findParentByType wont climb up the hierarchy past the parent menu. Is this by design or have I constructed my configuration incorrectly? The relevant pieces of my code are below:


Ext.namespace('SIPD.ProjectRecord');

SIPD.ProjectRecord.References = Ext.extend(Ext.grid.EditorGridPanel, {
initComponent: function() {
var config = {

...

tbar: [{
text: 'Add Reference',
iconCls: 'icon-add',
menu: {
items: [{
text: 'Add Link',
iconCls: 'icon-add-link',
handler: function(menuItem, event){
var grid = menuItem.findParentByType('projectRecordReferencesTab');
...
}
}, {
text: 'Upload Attachment',
iconCls: 'icon-add-document',
handler: function(menuItem, event){
var grid = menuItem.findParentByType('projectRecordReferencesTab');
...
}
}]
}
}]
};

// apply config
Ext.apply(this, config);
Ext.apply(this.initialConfig, config);

// call parent initComponent
SIPD.ProjectRecord.References.superclass.initComponent.call(this);
}
});

Ext.reg('projectRecordReferencesTab', SIPD.ProjectRecord.References);

Eric24
27 Sep 2009, 8:37 PM
Bump!

I'm having the same problem, and it appears that ownerCt is just not getting set in a menu object (regardless of overflow--I have toolbar buttons with menus, the toolbar button has ownerCt and the menu items themselves have ownerCt, but the menu itself does not).

Animal
5 Oct 2009, 2:37 AM
Toolbar Overflow does not work with regular Components. Try adding a ComboBox that goes off the edge. It just gets silently dropped.

cabal
18 Dec 2009, 3:01 AM
Fixed in SVN r5038.

It's broken again in 3.1.0
Fix is almost the same:



Ext.override(Ext.layout.ToolbarLayout, {
initMore : function(){
if(!this.more){
this.moreMenu = new Ext.menu.Menu({
listeners: {
beforeshow: this.beforeMoreShow,
scope: this
}
});
// does not work
// this.moreMenu.ownerCt = this.container.ownerCt;
this.more = new Ext.Button({
iconCls: 'x-toolbar-more-icon',
cls: 'x-toolbar-more',
menu: this.moreMenu,
ownerCt: this.container
});
var td = this.insertCell(this.more, this.extrasTr, 100);
this.more.render(td);
}
}
});

mystix
21 Dec 2009, 10:30 AM
marking this thread [REOPENED] in light of @cabal's latest finding.

hendricd
22 Dec 2009, 7:51 AM
Fixed in SVN.

Now you should be able to traverse upward from the overflow menuItem or the button itself.


{
text: 'Add Link',
iconCls: 'icon-add-link',
handler: function(menuItem, event){
var targetCmp = menuItem.parentMenu.ownerCt.findParentByType('someXType');
}
}