Combobox - default value - Ext JS

本文讨论了如何为使用远程数据源的组合框正确设置默认显示值和隐藏字段值。作者提出了一种方法,通过增加hiddenValue选项并在加载时进行判断来实现这一功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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?
Reply With Quote
  #2  
Old 03-09-2007, 04:27 PM
Default

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?
Reply With Quote
  #3  
Old 03-12-2007, 02:58 AM
Default

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;
Reply With Quote
  #4  
Old 03-13-2007, 01:00 AM
Default

Ah, I can add that to the main source. It makes sense. Thanks.
Reply With Quote
  #5  
Old 03-13-2007, 02:56 AM
Default

No problem, and thank you for adding it to the main source
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值