View Full Version : How to determine the active panel

12 Nov 2011, 4:49 PM
I have a tabPanel that contains multiple treePanels. Each treePanel has an add node function (and other functions) that are similar. I can add a different listener for each treePanel, but what I would like to do is have the same listener function for each, determine which panel is active and change the 1 or 2 relevant lines of code based on which panel is active. How can I determine which of the panels is active in this case? Or is this possible? Thanks for any suggestions.

12 Nov 2011, 6:35 PM

Will return the active component

13 Nov 2011, 2:01 PM
How would I refer to the tabPanel from within the treePanel listener? I tried tabs.getActiveTab(), but tabs was out of scope.

I tried using getCmp() without success. Perhaps I was using it in the wrong manner.

13 Nov 2011, 2:06 PM
If the tree is a child of the tabpanel then you can do:


13 Nov 2011, 2:21 PM
I think I'm asking the totally wrong question..

Here is a code snippet from an example which I based my code on:

var onCompleteEdit = function(treeEditor, newValue, oldValue) {
var treePanel = Ext.getCmp('treepanel')

Rather that write identical code for every "onCompleteEdit", I'd like to get the value of the active panel. The above code would work only for the 'treepanel' (which I couldn't quite get to work for me so I just referred directly to the treePanel object I defined. Obviously, I could write a listener and pass parameters to a function - but I think it would be cleaner if I could just test which panel called the listener and add the appropriate conditions within.

I appreciate your help.