How to change DisplayField text in ExtJs 3.0?

Duleep picture Duleep · Feb 6, 2013 · Viewed 9.2k times · Source

I want to change 'Labelxx' to 'New Label' in a DisplayField. How can I do this? Below is my code:

MyFormUi = Ext.extend(Ext.form.FormPanel, {
    title: 'Rates ',
    id: 'id_form',
    initComponent: function() {
        this.items = [{
            xtype: 'displayfield',
            fieldLabel: 'Labelxx',
            anchor: '100%',
            name: 'name_lb',
            ref: 'localCurrencylbl',
            id: 'id_lb'
        }];
        MyFormUi.superclass.initComponent.call(this);
    }
});

Answer

A1rPun picture A1rPun · Feb 6, 2013

To change DisplayField text:

Ext.getCmp('id_lb').setValue('New text');

To change the fieldLabel:

Ext.getCmp('id_lb').setFieldLabel('New Label');

Note: It is not recommended to work with id's tho.