1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    44
    Vote Rating
    0
    Answers
    1
    kramal is an unknown quantity at this point

      0  

    Default Unanswered: Alternatives Ext.getCmp() is Ext.ComponentQuery, but how use it right?

    Unanswered: Alternatives Ext.getCmp() is Ext.ComponentQuery, but how use it right?


    Hello Friends!

    I have problem with Ext.ComponentQuery.query().

    Several days ago I have finished my first application. But there I used Ext.getCmp() to get references.
    But I have read article where was explained why Ext.getCmp() is bad style. now I want to understand how works Ext.Component.Query.query() method. Here some testing example:111222.png

    Ext.onReady(
    function(){

    Ext.create('Ext.Panel',{
    renderTo:Ext.getBody(),
    title:'121212',
    width: 500,
    height: 200,
    layout:'column',
    items:[
    {
    xtype:'button',
    text:'Button',
    handler:function()
    {
    var btn=Ext.ComponentQuery.query('textfield');
    alert('some');
    btn[0].hide();
    btn[0].setRawValue('jjjj');
    }
    },
    {
    xtype:'textfield',
    fieldValue:'text'
    }
    ]
    });
    });

    I cant get results how i expected
    Last edited by kramal; 1 Feb 2013 at 12:22 AM. Reason: to make easy our life

  2. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      1  

    Default


    You could change your button handler to do something like this:

    Code:
    handler:function(){
      this.up('panel').down('textfield').setValue('jjjj');
    }
    Keep in mind that it's also perfectly fine to use itemId: 'someValue' on child components in a container. This just gives them a unique name within the parent container against which you can query:

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    44
    Vote Rating
    0
    Answers
    1
    kramal is an unknown quantity at this point

      0  

    Default


    Thank you ! I understand it

Thread Participants: 1

Tags for this Thread