-1

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();
                    }
                }
            );
        }
    }
}
Jazuly
  • 1,374
  • 5
  • 20
  • 43

3 Answers3

1

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.

mcg1103
  • 678
  • 1
  • 4
  • 9
0

First, this in your listener is not refer to a component such as combobox, etc. Maybe it refers to the store instance or the controller class. Try to make sure that you access the component instance. It can be determined by logging to console, a default component in ExtJs has a xtype property such as combobox,container,etc. Once you can access the component (parent component), you can find it's child which has named reference by using a function.

Second, based on their docs, You can get the component by it's reference by using parentComponent.getReferences()['PARTICULAR_REFERENCE_NAME'] function. a parentComponent can be a form, container, or etc. I don't know what version of ExtJS you are using, getReferences function maybe does not exist in lower version.

Dharman
  • 30,962
  • 25
  • 85
  • 135
starlight93
  • 126
  • 1
  • 6
  • i got error `parentComponent` not found or something like this.. – Jazuly Jan 24 '21 at 06:28
  • parentComponent means a variable which is initiated by selecting a component, for example: ``` var parentComponent = Ext.getCmp('YourParentComponentId'); ``` So it does not exist before and you must declare and initiate it first. So you can use it for the next line in your code. – starlight93 Jan 25 '21 at 09:29
0

If You want to fetch the ExtJS component in view as Above example.
Then you have enabled referenceHolder Property to true.

Refer to this link for example:
Fetching ExtJs Component in View

This property enables view as reference holder of component for more details
Please Refer sench docs link:
Sencha docs ReferenceHolder