PDA

View Full Version : Getting clicked button parent



Killer_B
9 Nov 2010, 12:10 AM
I'm trying like crazy to get clicked button parent but somehow failing at it.

I have multiple form panels with buttons and I would like to get the parent panel when I click on a button. I could write this in jquery in under a minute but I just can't figure it out in extjs. What I'm missing is "this", which would place me directly to button. From there I could easily traverse to it's parent.

Example in jquery.

$(this).parents(panel_class)

Condor
9 Nov 2010, 12:27 AM
handler: function(btn, e){
var form = btn.findParentByType('form');
...
}

Killer_B
9 Nov 2010, 12:32 AM
Thank you.

I did managed to get parent form with ownerCt property. It's just hard to find these things in documentation.

raj_plays
9 Nov 2010, 12:34 AM
Hi,
My query is similar...
I have a combo in a form and the form is in a window.
On 'expand' of the combo I want the window to come to the front.
What should the function be like?


listeners:
{
expand: function(combo){combo.findParent().findParent().toFront();}
}

Killer_B
9 Nov 2010, 12:37 AM
Hm...I've managed to get parent container of parent form of clicked button with code below if that helps?


removeHintRow: function(btn) {
var btnsForm = btn.ownerCt;
var btnsContainer = btnsForm.ownerCt;
var btnsContainerForm = btnsContainer.ownerCt;

btnsContainerForm.remove(btnsContainer);
this.doLayout();
}

Condor
9 Nov 2010, 1:42 AM
combo.findParentByType('window').toFront();
(but this will focus the window and possibly hide the combobox dropdown again)

Killer_B
9 Nov 2010, 1:44 AM
Just realized that you can chain ownerCt property.

So instead of 3 lines in code above, you can just write btn.ownerCt.ownerCt.ownerCt.

I know it's not the best way to do this, but it works exactly how I need it.

raj_plays
9 Nov 2010, 2:02 AM
Thank you, Condor and Killer_B.
I have 2 windows. The top one contains a combo. When the second window is in focus, if I click on the combo, it shows something like..
23223

Bringing the first window toFront does not help(as Condor predicted). What to do?

PS: Killer_B, sorry for hijacking your thread

Condor
9 Nov 2010, 2:21 AM
Write a getListParent method for the ComboBox that returns the body of the window (instead of the document body).

raj_plays
9 Nov 2010, 5:24 AM
I wrote this...gives error: object doesn't support this property or method
(window1 is the id of the window that contains the form that contains the combo)


{
xtype: 'combo',
....
getListParent : function()
{
return Ext.get('window1').getBody();
//the next line doesn't work either
return this.findParentByType('window').getBody();
},
listeners:
{
expand: function(combo){combo.findParentByType('window').toFront();}
}

}

Condor
9 Nov 2010, 5:43 AM
return this.findParentByType('window').body;

raj_plays
9 Nov 2010, 8:09 AM
With this code, the selection menu gets cropped as in...
23232

Please help display the entire list. It should come on top of the second window titled "Select Ads"

Condor
9 Nov 2010, 8:21 AM
OK, not getListParent, but getZIndex needs to be implemented (and return a bit more thant the current zindex of the window).

raj_plays
9 Nov 2010, 9:55 PM
I put this in my combo config... there is no change from the image posted above :(


getZIndex : function() {
return this.findParentByType('window').zindex + 50;
},
listeners: {
expand: function(combo){combo.findParentByType('window').toFront();}
}

Condor??

raj_plays
17 Nov 2010, 10:24 PM
Hi,
I have not been able to resolve this issue satisfactorily.
I have a window with a combo box and another window below it.
I want the expanded list from the combo to display on top of everything but some part of it always gets hidden.
Please refer to the image above and to the one on the previous page.

Anyone??