Results 1 to 5 of 5

Thread: getComponent just direct childs?

  1. #1
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
      0  

    Question 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
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,856
    Vote Rating
    88
      0  
    Longtime Sencha engineer. Now surplus to requirements apparently...

  3. #3
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
      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 User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,856
    Vote Rating
    88
      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.
    Longtime Sencha engineer. Now surplus to requirements apparently...

  5. #5
    Sencha User zig999's Avatar
    Join Date
    Mar 2008
    Posts
    62
    Vote Rating
    2
      0  

    Default

    Thaniks a lot Animal.
    Ill take a look in the ref property too.

    Have a good one.

    Zig

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •