PDA

View Full Version : getComponent just direct childs?



zig999
22 May 2009, 4:11 AM
Hi!

Is getcomponent just for direct childs?
Is there a function that can get a child under the container, using itemId, independet of what level it is located?

For example, I have a panel with two columns and each column has a textfield.


Ext.onReady(function() {

var panel1 = new Ext.Panel({
title: 'getComponentTest',
width: 600,
renderTo: Ext.getBody(),
defaults: {
columnWidth: .5,
layout: 'form'
},
items: [
{
itemId: 'column1',
items: [{
xtype: 'textfield',
itemId: 'textfield1'
}]
},
{
itemId: 'column2',
items: [{
xtype: 'textfield',
itemId: 'textfield2'
}]
}
]
});

console.log(panel1.getComponent('column1').getComponent('textfield1'));

});

Instead of:


console.log(panel1.getComponent('column1').getComponent('textfield1'));

I would like to be able to do:


console.log(panel1.getComponent('textfield1'));


Any sugestions? Best practices?

Thanks
Zig

Animal
22 May 2009, 4:40 AM
http://extjs.com/deploy/ext-3.0-rc1.1/docs/?class=Ext.Container

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/hideinherited.jpg

zig999
22 May 2009, 5:43 AM
Animal, sorry, but can you be more specific?
I read the documentation already. I just want to make sure what my options are, and what more experienced developers used to do.

I know I can use find method, like:


console.log(panel1.find('itemId','textfield1'));


What in your opinion is the best approach?

Sorry if I didn't get it just with the docs.:">

Thanks!

Zig

Animal
22 May 2009, 5:49 AM
You could use the ref config. It will be documented when the documentation is regenerated, but its not ni the docs yet. But some enterprising soul has already read the code and found out about it!: http://blog.edseek.com/archives/2009/05/21/extjs-30-ref-and-button-ownerct.

You also have findByType or findBy.

zig999
22 May 2009, 6:09 AM
Thaniks a lot Animal. :)
IŽll take a look in the ref property too.

Have a good one.

Zig