Dialog w/Combo Box - Ext JS

本文讨论了ExtJS中组合框的两个常见问题:当对话框移动时组合框下拉列表不同步移动的问题及如何清除组合框输入字段的值。提供了具体的解决方案,包括通过监听对话框移动事件来调整组合框位置以及直接操作DOM来清空输入。

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

I have a combo box in a dialog, if I have the box's list expanded and move the dialog the result box doesn't move with the dialog.
Reply With Quote
  #2  
Old 03-08-2007, 02:19 PM
Default

Also is there a way to clear the value field? Each time I open my dialog with the combo box I'd like to clear the previous result, since I'm only creating the combo once.

I've tried:
Ext.get('mycombo').value = "";
and combo.setValue()

I'm sure it's something easy I'm just missing. This control is great!!

Thanks for the help.
Reply With Quote
  #3  
Old 03-08-2007, 02:26 PM
Default

I haven't tried it, but maybe it shoud be something like:
Ext.get('mycombo').set({value: ""});
Reply With Quote
  #4  
Old 03-08-2007, 02:28 PM
Default

That doesn't seem to be it, also in a dialog there never seems to be a cursor in the combo and I can't seem to set it's focus....
Reply With Quote
  #5  
Old 03-08-2007, 03:01 PM
Default

Ext.get gets an Element.

You need a reference to the input object:

setValue() on a combobox uses the parameter as a key - it finds the record where the designated value field matches.

To simply clear the input field:

myCombobox.el.dom.value = "";
Reply With Quote
  #6  
Old 03-08-2007, 03:52 PM
DefaultRe: Dialog w/Combo Box

Quote:
Originally Posted by brant
I have a combo box in a dialog, if I have the box's list expanded and move the dialog the result box doesn't move with the dialog.
Quick and dirty hack :
dialog.on('move', function(dlg, x, y) {
   comboBox.list.alignTo(comboBox.el, comboBox.listAlign);
});
Reply With Quote
  #7  
Old 03-08-2007, 03:58 PM
Default

I've tried to search but found nothing. How can I find a widget associated to an input element without passong a reference? Is that possible? I know that Ext.get() returns an Element, is there an equivalent function for widgets?

I'm using the word widget for differentiating it from Element, I mean something like TextField or DateField.

Thank you.
Reply With Quote
  #8  
Old 03-08-2007, 06:10 PM
Default

If you are using a valueField constraint, they setValue('') will not work as it won't be found. You can call combo.el.setValue('') though if the field has been rendered.

If you aren't aren't using a valueField constraint, they setValue('') is the way to do it.

mdelanno, that is exactly what is needed. The sad thing is there is no way (currently) for the combo to know the mousedown occured since drag drop kills bubble of the mousedown. Since drag drop is part of Ext now, I will of course be correcting that.

fponticelli, if you include an id in your component config and the widget you are using extends component (like combobox) you can get a reference from the component manager from anywhere. Eventually I hope to move all widgets over to the component interface.

var combo = Ext.ComponentMgr.get('combo-id');
Reply With Quote
  #9  
Old 03-09-2007, 05:50 AM
Default

That's it, thank you very much.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值