javascript 用于选择选定值的 ExtJS 4 Combobox 事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15299182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:16:17  来源:igfitidea点击:

ExtJS 4 Combobox event for selecting selected value

javascriptcomboboxextjs4

提问by Dawid Mazur

For some reason I need to know when user has selected value from combobox even if it is already selected. "Select" event works only if user selects unselected item. I don't see any event like "itemclick" in the docs for combobox or picker. Any ideas?

出于某种原因,我需要知道用户何时从组合框中选择了值,即使它已经被选中。“选择”事件仅在用户选择未选择的项目时才起作用。我在组合框或选择器的文档中没有看到任何类似“itemclick”的事件。有任何想法吗?

回答by Molecular Man

ComboBoxuses BoundListfor representing dropdown list. BoundListfires itemclickevent. You can use ComboBox's listConfigconfig in order to setup BoundListlisteners:

ComboBox使用BoundList表示下拉列表。BoundList触发itemclick事件。您可以使用ComboBoxlistConfig配置来设置BoundList侦听器:

Ext.create('Ext.form.ComboBox', {
    // ...
    listConfig: {
        listeners: {
            itemclick: function(list, record) {
                alert(record.get('name') + ' clicked');
            }
        }
    }
}

Check out the demo.

查看演示