PDA

View Full Version : [CLOSED][3.0.0] ComboBox forceSelection is not used in setValue()



bbg
28 Jul 2009, 8:44 PM
Ext version tested:
Ext 3.0.0 GAAdapter used:
extDescription:
When setting ComboBox value using setValue() there is no check if forceSelection was installed. So I can set nonexistent value.See this URL : http://extjs.com/deploy/dev/docs/source/Combo.html#method-Ext.form.ComboBox-setValue


The result that was expected:
When forceSelection is 'true', setValue() should not set nonexistent value.The result that occurs instead:
No matter if forceSelection is true, it the value always sets.Proposed solution:
In Ext.form.ComboBox add check for forceSelection property:


setValue : function(v){
var text = v;
if(this.valueField){
var r = this.findRecord(this.valueField, v);
if(r){
text = r.data[this.displayField];
}else if(Ext.isDefined(this.valueNotFoundText)){
text = this.valueNotFoundText;
}
}

if(this.forceSelection && !r){
this.clearValue();
}else{
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = v;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = v;
}
return this;
},

mystix
28 Jul 2009, 8:54 PM
i think you've misunderstood the purpose of forceSelection
-- it only controls end-user/UI interaction, not programmatic manipulation.

bbg
28 Jul 2009, 9:18 PM
Ok. But it's worth to add another configuration property for this purpose. I've just created SelectBox widget from ComboBox using setValue() function mentioned above.

There exists another related issue:
If I use


editable: false

then i should also add


listeners: {
beforequery: function (e) {
e.query = '';
}
}


Or the combo won't show full items list if i select any.

mystix
28 Jul 2009, 9:26 PM
Ok. But it's worth to add another configuration property for this purpose. I've just created SelectBox widget from ComboBox using setValue() function mentioned above.

can't comment on that.
someone will probably need to put up a feature request on that.



There exists another related issue:
If I use


editable: false

then i should also add


listeners: {
beforequery: function (e) {
e.query = '';
}
}


Or the combo won't show full items list if i select any.

that's because the combo is configured with triggerAction: 'query' by default (see the docs for more info).
for non-editable combos, you'll probably want to set triggerAction: 'all'.
no need for that beforequery listener you have there.

bbg
28 Jul 2009, 9:51 PM
Thanks for your help, friend!
I eager to see the next revision of Ext available for free download/:)

evant
28 Jul 2009, 10:22 PM
Marking this as closed, what Marc has said is correct.