PDA

View Full Version : [FIXED-273][3.0.0] ComboBox does not select on blur when forceSelection is true



Animal
4 Aug 2009, 4:54 AM
<select> boxes select the currently highlighted option on blur.

Right now, ComboBoxes with forceSelection: true do not do this.

Go to http://extjs.com/deploy/dev/examples/form/combos.html

Focus on a state Combo. Type "Miss". It will highlight "Mississippi". Then just click the mouse outside the Combo. It does not select the highlighted record.

It will select if you tab off the Combo.

The problem can be fixed by



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 : '';
this.applyEmptyText();
}else{
this.clearValue();
}
}else{
//var rec = this.findRecord(this.displayField, val);
if(rec){
val = rec.get(this.valueField || this.displayField);
}
this.setValue(val);
}
}
});

Animal
27 Sep 2009, 10:40 PM
Bump? This is still there.

evant
27 Sep 2009, 11:28 PM
Fix applied to svn in rev #5428 for patch release 3.0.3.

durlabh
28 Sep 2009, 2:27 PM
Shouldn't this patch be applied in 2.x branch too?

angelflaree
16 Oct 2009, 11:03 AM
Hi, folks

I found a similar problem in the combo box in EXT 3.0. Not sure if this has been solved.
That if I use a static store for the combo. After selecting a value from the dropdown option list and move focus to somewhere else. The combo changes value to display the value I set in the "valueNotFoundText" config. I found It's because when I move focus away, the value of the field is setting to its raw value("displayField" value), not the "valueField" value.

I have to set "forceSeletion: true" to solve this.

The problem is caused by the "beforeBlur:" method in the combo.js

An example of the combo I created to show the problem:


var myCostType = Ext.extend(Ext.form.ComboBox, {
fieldLabel: "Cost Type",
name: "costTypeCombo",
displayField:'costDisplay',
valueField: 'costValue',
emptyText: 'Select a cost method...',
valueNotFoundText: 'No Matching Found',
editable: false,
forceSelection: true, //If NOT USE, WILL HAVE THE ISSUE HERE
listWidth: 200,
triggerAction: 'all',
hideTrigger: false,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['costDisplay','costValue'],
data: [
['L-Last','L']
,['A-Average','A']
,['S-Standard','S']
,['F-Fifo','F']
,['G-Lifo','G']
]

})

});