ExtJS ComboBox triggerAction: "all" 是什么意思?真的吗? [英] What does ExtJS ComboBox triggerAction: "all" really do?
问题描述
我尝试创建一个简单的组合框:
I tried to create a simple ComboBox:
var combo1 = new Ext.form.ComboBox({
store: [1,2,3],
renderTo: document.body
});
但是这样写却很奇怪:
- 当您第一次打开下拉菜单时,它会提供三个选项.
- 您选择一个.
- 但是当您之后尝试更改您的选择时,下拉菜单只提供一个选择 - 您之前选择的那个.
我将我的代码与 Ext 主页上的 samples 进行了比较并发现添加 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 指定的查询配置选项(默认为查询")
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
到底有什么作用?
So what does this triggerAction
really do?
当我只想要一个简单的静态组合框时,将它设置为 "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屋!