什么是ExtJS ComboBox triggerAction:“all”真的吗 [英] What does ExtJS ComboBox triggerAction: "all" really do?
问题描述
我试图创建一个简单的ComboBox:
I tried to create a simple ComboBox:
var combo1 = new Ext.form.ComboBox({
store: [1,2,3],
renderTo: document.body
});
但是以这种方式写得很奇怪:
But written this way it acts strangely:
- 当您第一次弹出下拉菜单时,它提供三个选择。
- 您选择一个。
- 但是当您尝试更改您的选择后,下拉列表仅提供一个选择 - 您之前选择的选项。
我比较了我的代码到Ext主页上的示例,并发现添加 triggerAction:all
解决了我的问题:
I compared my code to the samples on Ext homepage and discovered that adding triggerAction: "all"
solves my problem:
var combo2 = new Ext.form.ComboBox({
triggerAction: "all",
store: [1,2,3],
renderTo: document.body
});
triggerAction
的ExtJS文档不告诉我很多:
ExtJS documentation for triggerAction
doesn't tell me a lot:
单击触发器时执行的操作。
使用'all'运行由allQuery
config选项指定的查询(默认为'query')
The action to execute when the trigger is clicked. Use 'all' to run the query specified by the allQuery config option (defaults to 'query')
我没有指定allQuery选项。实际上,我根本不想对服务器执行查询。
I haven't specified the allQuery option. Actually, I don't want to perform a query to the server at all.
那么这个 triggerAction
真的吗?
并将其设置为all
真的我应该做什么,当我想要一个简单的静态组合框?
And is setting it to "all"
really what I should do when I just want a simple static combobox?
推荐答案
选择项目后,列表将被过滤以匹配当前的文本值。在你的情况下,它总是完全是所选择的值,但是在多个字符值中更为明显(参见Ext中的状态名称示例)。如果删除所选值,下拉菜单将返回到所有值。 triggerAction:'all'
表示不要过滤,始终显示所有值。
After choosing an item, the list is filtered to match the current text value. In your case, it's always exactly the chosen value, but is more obvious with multi-character values (see the state names example in Ext). If you delete the selected value, the dropdown will go back to having all values. triggerAction:'all'
means do not filter, always show all values.
这篇关于什么是ExtJS ComboBox triggerAction:“all”真的吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!