Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extjs Combobox typeahead / auto selection for single character

I am using extjs combobox for a sex field. It have two value "M" and "F". I want to make it usable with keyboard:

 {
     xtype: 'combo',
     typeAhead: true,
     queryMode: 'local',
     minChars: 1,
     triggerAction: 'all',
     store: [
          ['M', 'M'],
          ['F', 'F']
     ]
 }

This works if I type "Ftab" (uppercase), but not "ftab" (lowercase). If I check the code to this, the typeahead works:

 store: [
     ['M', 'Male'],
     ['F', 'Female']
 ]

Any ways to keep the value as "M" and have lowercase works?

like image 295
J-16 SDiZ Avatar asked Jun 02 '11 12:06

J-16 SDiZ


2 Answers

not sure if you figured this one out, but I had a similar problem and found the solution:

enableKeyEvents : true,
forceSelection : true,
typeAhead : false,
    listeners : 
    {
        'keyup' : function(me)
        {
            var val = me.getRawValue();
            if(val == 'm' || val == 'f')
                me.setValue(val.toUpperCase());
        }
    }

I also had a grid that was giving me grief for a simple yes/no type selection in a combobox. I have searched high and low for an answer, but came up with this hack.

Hope it helps!

like image 114
stagl Avatar answered Sep 17 '22 17:09

stagl


Set the combobox 'caseSensitive' config attribute to false (caseSensitive : false). This should solve problem.

like image 24
extjs-world.blogspot.com Avatar answered Sep 20 '22 17:09

extjs-world.blogspot.com