PDA

View Full Version : access ext components



topcoder1
17 Aug 2007, 12:14 PM
I have the following code:
var c=new Ext.ContentPanel('myid',{autoCreate:true,id:myid});
var x=Ext.get('myid');
x seems to be the html container of c, is there a way to obtain c given 'myid'?

para
17 Aug 2007, 1:04 PM
I'm assuming that you're putting the ContentPanel 'c' into a layout of some kind...
Generally the way to get 'c' would be to say something like...


layout.getRegion('west').getPanel('myid');


or you could write a global function like:


getPanel: function(region, panelId) {
layout.getRegion(region).getPanel(panelId);
}

Does this help?

topcoder1
17 Aug 2007, 1:39 PM
hey para, my case is actually more completed I have basically an Accordion for my left navigation bar, it contains many InfoPanels, for each InfoPanel, I have a TreePanel. My problem is that I have no way of getting the TreePanel once it's built. I can not assign an id to it either the way it's built.


for ( var i = 0; i < oElement.nav.length; i++) {
if (oElement.nav[i].title) {


var el=leftnav.add(new Ext.ux.InfoPanel(oElement.nav[i]));
var sub_menu =new xt.TreePanel(el.body, {
id:el.id,
animate:true,
enableDD:true,
containerScroll: true,
lines:false,
rootVisible:false
});

Animal
18 Aug 2007, 10:42 PM
You got to become OO. Perhaps a sigleton object to manage these. Something like (completely off the cuff code):



myNavigationController = Ext.apply(new Ext.util.Observable(), {
infoPanels:{},

navTrees: {},

createNavPanels: function() {
for ( var i = 0; i < oElement.nav.length; i++) {
if (oElement.nav[i].title) {

var id = Ext.getDom(oElement.nav[i]).id;
this.infoPanels[id] = new Ext.ux.InfoPanel(oElement.nav[i]);
var el=leftnav.add(this.infoPanels[id]);
this.navTrees[id] = new xt.TreePanel(el.body, {
id:id,
animate:true,
enableDD:true,
containerScroll: true,
lines:false,
rootVisible:false
});
}
}
}
});

topcoder1
19 Aug 2007, 3:34 PM
According to the doc, Ext.apply copies every property of the second arg into the first arg ob ject, does this make a copy of all my navigational components? and does this mean myNavigationController will receive all the events as well?
thanks


You got to become OO. Perhaps a sigleton object to manage these. Something like (completely off the cuff code):



myNavigationController = Ext.apply(new Ext.util.Observable(), {
infoPanels:{},

navTrees: {},

createNavPanels: function() {
for ( var i = 0; i < oElement.nav.length; i++) {
if (oElement.nav[i].title) {

var id = Ext.getDom(oElement.nav[i]).id;
this.infoPanels[id] = new Ext.ux.InfoPanel(oElement.nav[i]);
var el=leftnav.add(this.infoPanels[id]);
this.navTrees[id] = new xt.TreePanel(el.body, {
id:id,
animate:true,
enableDD:true,
containerScroll: true,
lines:false,
rootVisible:false
});
}
}
}
});