清除 ExtJS 组合框输入字段
我有一个具有以下属性的 Ext.form.ComboBox:
fieldLabel: 'Regiune',
valueField: 'id',
displayField: 'reg',
id: 'cbRegR',
typeAhead: true,
store: new Ext.data.JsonStore({...}),
mode: 'local',
emptyText: '',
listeners:{...}
问题是,在从下拉列表中选择一个值以查看所有列表项后,我必须手动删除组合框的输入字段。问题是列表仅显示输入字段中以字母开头的项目。
如何清除扩展下拉列表中的输入字段?我尝试了以下方法,但不起作用:
listeners: { 'expand': function() { cbRegR.clearValue(); } }
似乎很容易,但对我来说并非如此..有什么好主意吗?提前致谢。
I have an Ext.form.ComboBox with the following properties:
fieldLabel: 'Regiune',
valueField: 'id',
displayField: 'reg',
id: 'cbRegR',
typeAhead: true,
store: new Ext.data.JsonStore({...}),
mode: 'local',
emptyText: '',
listeners:{...}
The problem is that I have to manually delete the combobox' input field after selecting a value from the dropdown list to view all the list items. The matter is the list displays only the items that begin with letters in input field.
How can I clear the input field on expanding dropdown list? I tried the following but it doesn't work:
listeners: { 'expand': function() { cbRegR.clearValue(); } }
Seems to be easy but it ain't so for me.. Any bright ideas? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将配置属性添加到组合框
可能会解决问题,而无需注册展开事件处理程序或清除组合框的值
Adding the config property to your combobox
might do the trick, without the need to register an expand event handler or clearing the combobox's value
正如您所知,根据字段值过滤列表项是 Ext JS ComboBox-es 的固有行为。
您可以明显地重写 Expand() 方法,在呈现列表之前进行添加以清除该值。例如:
It is an intrinsic behaviour of Ext JS ComboBox-es to filter the list items based on the field value, as you already know.
You could perceivably override the expand() method, making additions to clear out the value before it renders the list. EG:
扩展事件是个好事件,但您必须小心其范围。
设置范围有帮助吗?
The expand event is the good one but you have to be careful about the scope.
Does setting the scope helps?
使用
cbRegR
不起作用,因为它是一个未定义的变量。使用或者,更复杂的方法:
Using
cbRegR
won't work, because it's an undefined variable. Either useor, a more sophisticated approach: