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
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