Real Dreams
Real Dreams

Reputation: 18020

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();
        });
    }
});

Upvotes: 2

Views: 2111

Answers (2)

Tyr
Tyr

Reputation: 2810

I made a fiddle for you: https://fiddle.sencha.com/#fiddle/fj5

It works like a charm. Maybe you have some other problems in your code.

Upvotes: -1

sra
sra

Reputation: 23983

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()})

Upvotes: 2

Related Questions