如何让 extjs 组合框像普通的 html 选择框一样工作?
ExtJS 提供了一个精美的组合框,它具有很多功能 - 提前输入、允许随机文本输入、隐藏下拉列表中不以已输入文本开头的所有条目。
我不想要这些功能。我想要一个选择框,其行为与普通 html 中的普通选择框非常相似。
我确实希望它绑定到数据存储,并且我确实想要组合框附带的所有其他 extjs 配置好东西。我只是不想让用户/测试人员在遇到一个选择框时感到惊慌,因为这个选择框打破了他们现有的这些东西如何工作的思维模式。
那么如何才能让 extjs 组合框更像选择框呢?或者我完全使用了错误的小部件?
ExtJS provides a fancy combo-box that has lots of features - type ahead, allowing for random text entry, hiding all the entries in the drop-down list that don't star with the text that has already been entered.
I don't want these features. I want a select box that behaves pretty much exactly like one would expect a normal select box would in vanilla html.
I do want it bound to a data store, and I do want all the other extjs configuration goodies that come with the combo box. I just don't want users/testers freaking out when they encounter a select box that breaks their existing mental paradigm of how these things work.
So how can I get an extjs combo box to act more like a select box? Or am I using the wrong widget altogether?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在实例化 Ext.form.ComboBox 对象时,只需使用正确的配置即可获得该行为:
在您的情况下,替换
mode: 'local'
和store
参数例如,您希望将其绑定到Ext.data.JsonStore
。You can get that behaviour just by using the proper configuration when you instantiate the Ext.form.ComboBox object:
Replace the
mode: 'local'
andstore
argument in your case if you'd like it to be bound to aExt.data.JsonStore
for example.目前接受的解决方案效果很好,但如果有人想要一个像普通 HTML 选择框一样处理键盘输入的 ComboBox(例如,每次按“P”时都会选择列表中以“P”开头的下一个项目),则以下可能会有所帮助:
The currently accepted solution works great, but if anyone wants a ComboBox that also handles keyboard input like a plain HTML select box (e.g., each time you press "P" is selects the next item in the list beginning with "P"), the following might be helpful:
您尝试过
typeAhead = false
吗?不太确定这是否接近您想要的。Did you try
typeAhead = false
? Not too sure if this is close to what you want.只需使用 Ext.merge 函数
来自文档:http://docs.sencha.com/extjs/4.2.1/#!/api/Ext-method-merge
Just use
Ext.merge
functionFrom the doc: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext-method-merge