Search code examples
extjscomboboxextjs4

Opening combos after getting focus


I need a combo's menu to be open after getting focus automatically. Changing minchar config was not effective. Is there any other config for this purpose?

Update:

Ext.define("My.form.combo.Local", {
    extend: "Ext.form.ComboBox",
    xtype: 'local-combo',
    queryMode: 'local',
    minChars: 0,
    selectOnFocus: true,
    forceSelection: true,
    typeAhead: true,
    initComponent: function () {
        this.callParent();
        this.on('focus', function () {
            console.log('f');
            this.expand();
        });
    }
});

Solution

  • The following snipped worked in ExtJS 4.2.3

    You can control the picker with expand and collapse

    // The data store containing the list of states
    var states = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
            //...
        ]
    });
    
    // Create the combo box, attached to the states data store
    var c =Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: states,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    
    c.on('focus',function(c){c.expand()})