Hacker
Hacker

Reputation: 7906

Set default selected value in extjs6 comboBox

I have made code like below

Ext.define('Abc.store.Indicator', {
    extend: 'Ext.data.Store',
    alias: 'store.indicator',
    fields: ['key', 'value'],
    proxy: {
        type: 'memory',
        reader: {
            type: 'array'
        }
    },
    data: [
        ["ALL", "ALL"],
        ["Y", "Y"],
        ["N", "N"]
    ]
});

Ext.define('Abc.view.main.Indicator', {
    extend: 'Ext.form.field.ComboBox',
    xtype: 'indicator',
    fieldLabel: 'Ind',
    name: 'indicator',
    displayField: 'value',
    valueField: 'key',
    store: {
        type: 'indicator'
    }
});

and in report items i use like

 items: [{xtype:'indicator'}]

When user opens the report, i want 'N' to be displayed as default value. How do i do this. I set 'value' key, but when dropdown is opened, selected value is different.

Upvotes: 0

Views: 305

Answers (1)

Au_ww
Au_ww

Reputation: 26

Maybe you can put queryMode: 'local' in the config of 'Abc.view.main.Indicator', or the store will load.

Here is the key code classic/classic/src/form/field/ComboBox.js line 1562

    if (lastSelected && selectionModel.selected.length && store.indexOf(lastSelected) > -1) {
            itemNode = lastSelected;
    }

So the new Store doesn't has the lastSelected which you set.

Upvotes: 1

Related Questions