Combobox - default value - Ext JS

1568 ワード

I use a remote dataset with a key=>value combobox. I got it working without much problems. The only thing I'm missing is to set a default value for the valueField AND the displayField. Is this not supported (yet) or am I just missing something?
  #
2  
03-09-2007, 04:27 PM
What do you mean, when it's loaded? You can pass in a value: 'foo', or it will read an existing text field for its value, or if tranforming a select it will use the selects selected value. Is that not what you want?
  #
3  
03-12-2007, 02:58 AM
I have a combobox with a JSON source. When the combobox loads there are no records available yet to the combobox. Also, I don't want to trigger a http-request just to fetch the default value.
My combobox uses the hidden field to supply a key instead of the displayed value.
To correctly set the default value I have to set both the display value and the hidden key value.
EDIT:
I just tried to add it to your code and it was actually very simple. I added the option hiddenValue and changed line 108 (was 107 before adding the hiddenValue option):
            this.hiddenField.value = this.value;

to
            this.hiddenField.value = this.hiddenValue || this.value;

  #
4  
03-13-2007, 01:00 AM
Ah, I can add that to the main source. It makes sense. Thanks.
  #
5  
03-13-2007, 02:56 AM
No problem, and thank you for adding it to the main source