Search code examples
extjsextjs4

Change config options on fly in ExtJS


Explain me important question, please! I created a Label with list of options:

 var labelCombo = Ext.create('Ext.form.Label', {
    forId: 'hostT',
    text: 'My Awesome Field',
    margins: '0 20 0 20'
});

Now I need to change config options by event of other component:

xtype: 'button', text: 'Refresh', handler : function() {
        //actions here
}

I tried to change config like so:

Ext.apply(labelCombo, {text: 'New text'})

But without success. Is there possibility to change config options by event?


Solution

  • Considering the you are trying to change the text value of the label..

    if you specify "myLabel" as your label's itemId, then you could use

    Ext.ComponentQuery.query('#myLabel')[0].setText("New text");
    

    to update text of the label.