Wednesday, May 4, 2011

ExtJS -=- ComboBox TypeAHead useful hack


Here is a useful hack that disable the auto selection of the first record while searching data in a combo box with the Type Ahead functionnality.

If there is only one record, the combo will automatically selects the first record. You just need to add this override to your code.

 * When we are looking for an item in a combo box by typing data in the combo
 * box, the combo usually used to take the first record and replace the actual
 * typed data. This override disable this functionnality so we can enter data
 * and use the filters.
 * If there is only one result, the combo automatically selects the first record.
Ext.override(Ext.form.ComboBox, {
    onTypeAhead : function(){
        if( === 1){
            var r =;
            var newValue =[this.displayField];
            var len = newValue.length;
            var selStart = this.getRawValue().length;
            if(selStart != len){
                this.selectText(selStart, newValue.length);

No comments:

Post a Comment