javascriptextjssencha-architect

How to get value from reference in ExtJS


i have problem with ext js, i want to get value from my field using reference in my store, but when i console.log i got error lookupReference is not a function.

my form

items: [
    {
        xtype: 'combobox',
        name: 'REC_TERMINAL_CODE_2',

        fieldLabel: 'Terminal 2',
        emptyText : 'Terminal',
        reference: 'terminal2'
    },
    {
        xtype: 'combobox',
        name: 'REC_TERMINAL_CODE',

        fieldLabel: 'Terminal',
        emptyText : 'Terminal',

        store: {
            type: 'terminal'
        },

        displayField: 'terminal_name',
        valueField: 'terminal_code',
        value: 'T01',
        
        minChars: 3,
        queryParam: 'q',
        queryMode: 'remote',

        editable: false,
        allowBlank: false,

        fieldStyle: 'text-transform:uppercase',

        afterLabelTextTpl: [
        '<span style="color:red;font-weight:bold" data-qtip="Required"> *</span>'
        ],

        flex: 1
    },
]

in my terminal store file

listeners: {
    load: function (store, records, success) {
        console.log(this.lookupReference('terminal2'))
        if (!success) {
            Ext.Msg.confirm('Status Error', 'This connection failed, reload ?',
                function (choice) {
                    if (choice === 'yes') {
                        window.location.reload();
                    }
                }
            );
        }
    }
}

Solution

  • A store is not a component so you can use getReferenceHolder(). You can use the generic Ext.ComponentQuery.query('combobox[reference=terminal2]')[0]

    This would return an array of components that fit the query.