tobiu
26 Jun 2009, 7:56 AM
hi together,
since this is neither a question nore a bug report, i post this here under "general".
in ext2.x this feature was buggy (see my report under http://extjs.com/forum/showthread.php?t=64695 ), now it is working technically correct, but i am not sure if this is the best way.
in ext3-rc2 onBeforeBlur checks, if a value was selected (by clicking into the menu) and if not resets the field. if you type exactly the same text like a displayField value of the store, the field will get reset, since you did not click on the item.
i would prefer a way, where you can type text and if that text matches exactly a value of the store, "forceSelection" is fullfilled.
my ext2.x hotfix is an working approach to simulate it:
Ext.override(Ext.form.ComboBox, {
validate : function(){
var prevVal = Ext.form.ComboBox.superclass.validate.call(this);
if(prevVal === false)return false;
if(this.forceSelection && this.rendered && !this.disabled){
if(this.el.dom.value.length > 0){
if(this.store.find(this.displayField, this.el.dom.value) !== -1)return true;
if(this.store.getCount() == 0 && this.value && this.hiddenValue)return true;
this.markInvalid('not a selected value!');
return false;
}
}
return true;
}
});
the user gets the chance to type text, if it does not match a value of the store, the field will get marked invalid instead of deleting the input. to make this working in ext3, onBeforeBlur has to be modified (the forceSelection part has to be removed).
i have no problem to use overrides for my own app, but would like to hear other opinions on this.
kind regards, tobiu
since this is neither a question nore a bug report, i post this here under "general".
in ext2.x this feature was buggy (see my report under http://extjs.com/forum/showthread.php?t=64695 ), now it is working technically correct, but i am not sure if this is the best way.
in ext3-rc2 onBeforeBlur checks, if a value was selected (by clicking into the menu) and if not resets the field. if you type exactly the same text like a displayField value of the store, the field will get reset, since you did not click on the item.
i would prefer a way, where you can type text and if that text matches exactly a value of the store, "forceSelection" is fullfilled.
my ext2.x hotfix is an working approach to simulate it:
Ext.override(Ext.form.ComboBox, {
validate : function(){
var prevVal = Ext.form.ComboBox.superclass.validate.call(this);
if(prevVal === false)return false;
if(this.forceSelection && this.rendered && !this.disabled){
if(this.el.dom.value.length > 0){
if(this.store.find(this.displayField, this.el.dom.value) !== -1)return true;
if(this.store.getCount() == 0 && this.value && this.hiddenValue)return true;
this.markInvalid('not a selected value!');
return false;
}
}
return true;
}
});
the user gets the chance to type text, if it does not match a value of the store, the field will get marked invalid instead of deleting the input. to make this working in ext3, onBeforeBlur has to be modified (the forceSelection part has to be removed).
i have no problem to use overrides for my own app, but would like to hear other opinions on this.
kind regards, tobiu