PDA

View Full Version : Combox adjust display after combobox.setValue().



hevole
29 Nov 2010, 2:59 PM
Hello Fellow ExtJs Community Members,

I have a combobox that takes a pair of data as each record of its store, one as the valuefield and the other as the display field.


var combobox = {
xtype:'combo',
displayField:'value',
valueField:'id',
store:store
...
}

where the store is configured to take values of the form:

{data:[{id:1,value:'apple'}, {id:2,value:'orange'}.....]}

Doing
combobox.setValue(<a valid id value>); would make the combobox properly select the record( this is testified after seeing the combobox submitting the correct value upon form submit), however the value it displays is the value in the id instead of the one in the display field. in the context of my example,
combobox.setValue(1) would make the 'apple' entry selected in the combobox's drop down list, however the combox's display is simply 1 instead of 'apple'.

Question is how to make the combobox display the display field, instead of the value that was just set.

Thanks.

Condor
30 Nov 2010, 12:16 AM
This does work correctly when the store is loaded before you set the value.

You might want to use this patch (http://www.sencha.com/forum/showthread.php?75751-OPEN-42-ComboBox-s-setValue-call-with-a-remotely-loaded-Store&p=400274#post400274) for that.