PDA

View Full Version : [2.2][OPEN] combo with forceSelection:false doesn't show isdirty



saJoshua
12 Aug 2008, 11:53 PM
Hi,

I have a combo with forceSelection not set to true. It doesn't show that it "is dirty" when text is typed into the field.

Checking the code for the combo:


// from combo.js
getValue : function(){
if(this.valueField){
return typeof this.value != 'undefined' ? this.value : '';
}else{
return Ext.form.ComboBox.superclass.getValue.call(this);
}
}


and considering that isDirty compares the "getValue" and "originalValue"



// from field.js
isDirty : function() {
if(this.disabled) {
return false;
}
return String(this.getValue()) !== String(this.originalValue);
}


I think that the problem is that the custom typed text isn't stored in the "valueField" of the combo. I implemented the following override, change highlighted, that seems to work. Can someone on the extjs team confirm that this would be the correct way to do this?



Ext.override(Ext.form.ComboBox, {
getValue : function(){
if(!this.forceSelection && this.store.find(this.valueField,this.getRawValue()) <= 0){
return this.getRawValue();
}else if(this.valueField){
return typeof this.value != 'undefined' ? this.value : '';
}else{
return Ext.form.ComboBox.superclass.getValue.call(this);
}
}
});


Joshua

brian.moeskau
23 Sep 2008, 11:25 PM
We have several similar issues posted relating to combo validation and how the value is managed internally. I'll add this one to the list to look at.

MartiCode
17 Apr 2009, 5:18 AM
I have comparable problem with 3.0 RC1 : typing anything other than what is in the combo list isn't returned by getValue() :


<input type="text" id="array-states" size="20"/>

<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();

var comboFromArray = new Ext.form.ComboBox({
id: 'combo1',
xtype: 'combo',
name: 'Categories',
fieldLabel: 'Categories',
store: ['a','b'],
typeAhead: true,
triggerAction: 'all',
mode: 'local',
forceSelection: false,
applyTo: 'array-states'
});
});
</script>
Ext.getCmp('combo1').getValue() should return whatever is typed but it'll return nothing or the last value selected in the list.