View Full Version : [Solved] Combobox with forceSelection does not select

4 Aug 2009, 4:06 AM
I have ComboBox to select numbers 1 to 60 with forceSelection and typeAhead.
If I type in e.g. 42 and click on the next textbox the Combobox remains empty.

If I click on 42 in the list or use tab to get in the next field it works but not if you click after typing. It also works if I disable forceSelection but I like to have forceSelection...

Couldn't find a fix for this here...

var combo = new Ext.form.ComboBox({
store: pagerNumbersStore,
valueField: 'name',
displayField: 'name',
id: 'pager_number',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
value: pagerNumber,
forceSelection: true,
maskRe: /[0-9]/,
renderTo: Ext.get('pager_number_div')
});ExtJs version is 3.0 RC2.

4 Aug 2009, 4:12 AM
Seems a stunningly pointless ComboBox. Type "42", and it selects "42"?

4 Aug 2009, 4:26 AM
Not really because 42 is just a short name for a very long number and not all numbers are available all the time. That's why I like to have forceSelection.

But anyway beside of what is in the combobox, it is really unexpected if a valid value is not excepted just because I click with the mouse instead of using the tab key.

4 Aug 2009, 4:35 AM
I think you have to select the entry. It must recieve some event to say "yes, select that".

So Tabbing selects it.

In reality going backwards and forwards between keyboard and mouse is very annoying for users. If you are writing an application, the users will learn to use the keyboard, and clatter through it without taking their hands off the keyboard.

4 Aug 2009, 4:39 AM
On second thoughts, I think you have a point, and it's a bug.

Try this override:

Ext.override(Ext.form.ComboBox, {
beforeBlur : function(){
var val = this.getRawValue();
var rec = this.findRecord(this.displayField, val);
if(!rec && this.forceSelection){
if(val.length > 0 && val != this.emptyText){
this.el.dom.value = Ext.isDefined(this.lastSelectionText) ? this.lastSelectionText : '';
val = rec.get(this.valueField || this.displayField);

4 Aug 2009, 4:43 AM
This problem is reality. I am here because I have several user how have reported this problem.

Your override fixes the problem. Thanks a lot!

4 Aug 2009, 4:55 AM
Reported: http://extjs.com/forum/showthread.php?p=368265