1. #1
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
    zig999 is on a distinguished road

      0  

    Question getComponent just direct childs?

    getComponent just direct childs?


    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.
    Code:
    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:
    Code:
    console.log(panel1.getComponent('column1').getComponent('textfield1'));
    I would like to be able to do:
    Code:
    console.log(panel1.getComponent('textfield1'));
    Any sugestions? Best practices?

    Thanks
    Zig

  2. #2

  3. #3
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
    zig999 is on a distinguished road

      0  

    Default


    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:
    Code:
    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

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    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...button-ownerct.

    You also have findByType or findBy.

  5. #5
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
    zig999 is on a distinguished road

      0  

    Default


    Thaniks a lot Animal.
    I´ll take a look in the ref property too.

    Have a good one.

    Zig

Thread Participants: 1