什么是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
});
但这样写的方式奇怪:
- 当您第一次弹出打开下拉菜单时,它会提供三个选择。
- 您选择一个。
我比较了我的代码到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
});
ExtJS文档 triggerAction
我有很多:
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屋!