Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJs 4, How to prevent xtype: 'combo' from collapsing when already selected item clicked?

I have ComboBox. When I click on item from expanded list, ComboBox select this item and collapse. If I click on already selected item it also collapsing.

Is there a way to "stop" ComboBox collapsing when user select already selected item?

PS: to be short i want ComboBox to behave like TimeField from http://dev.sencha.com/deploy/ext-4.0.0/examples/themes/index.html

UPDATE

I don't need solutions that dosen't work at least at IE7 and IE8..

like image 994
obenjiro Avatar asked Apr 27 '11 10:04

obenjiro


2 Answers

var cb = new Ext.form.ComboBox({    
    // here is your local store
    mode: 'local',
    store: new Ext.data.SimpleStore({
        fields: ['id', 'label'],
        data: [
            ['1', 'One'],
            ['2', 'Two']
        ]
    }),    
    listeners: {
        'beforeselect': function (combo, record, index) {
            // prevent collapsing if the same value is selected
            if (record.data.label == combo.getRawValue()) return false;
        }
    }
});
like image 133
Deniz Avatar answered Nov 13 '22 09:11

Deniz


If you want that behaviour:

Ext.form.field.ComboBox.override({
    onItemClick: Ext.emptyFn
});
like image 45
Evan Trimboli Avatar answered Nov 13 '22 08:11

Evan Trimboli