How to change value of extJS textfield component inside extJS panel

extjsextjs4

I'm here with so easy question, but couldn't find it… anyway, below you can see the code. This is panel with items inside it.
What i want is to change value of textfield with name 'intIP', it's inside panel, which is inside panel.
How can i do that? I found info about forms (.getForm method, but panel doesn't have such)

Thanks a lot in advance

http://jobtask.h19.ru/ – panel

var resultsPanel = Ext.create('Ext.panel.Panel', {
    title: title,
    renderTo: document.body,
    layout: {
        type: 'vbox',
        align: 'stretch',
    },
    items: [{
        title: 'Details',
        name: 'detPanel',
        items: [{
            name: 'intIP',
            fieldLabel: 'internal IP',
            xtype: 'textfield',
            readOnly: true
        }],
    }]
});

Best Answer

In ExtJS 4 you should be able to use Ext.Container.query() method, which when passed a correct selector will return array of children components that match the selector.

resultsPanel.query('textfield[name="intIP"]')[0].setValue('New value')

Details on how to create selectors are here: http://localhost/ext-4.0.2/docs/index.html#/api/Ext.ComponentQuery


In ExtJS3: Every Ext.Container has a find() method, which can be ginven a name of property (name,xtype,itemId etc) and a value ('intP', 'textfield', 'fieldId'). It will return an array of chlderen components (at any level of nesting) where property has the indicated value. If in your container only one field has a name 'intP' then you can just use:

resultsPanel.find('name','intP')[0].setValue('New value')

In both ExtJS3 and ExtJS4 if you have more children components with same name, using additional unique property like itemId should help.

Related Topic