对EXTJS中的同一选择器使用不同的事件



在网格上,我需要监听itemclick和itemkeydown操作,但当我在控制器中添加这两个操作时,它们都不会被触发。这个代码有什么问题?

如何在网格的组合框编辑器上收听按键事件?

http://jsfiddle.net/WRXcw/3/

        'definitiontypeform dtpropertylist': {
            itemclick: this.doSelectPropertyGrid
        },
        'definitiontypeform dtpropertylist': {
            itemkeydown: this.doAddInitial
        },

尝试以下

'definitiontypeform dtpropertylist': {
    itemclick: this.doSelectPropertyGrid,
    itemkeydown: this.doAddInitial
},

您可以在同一选择器中添加多个要侦听的事件。

在代码中,将同一个键添加到控制对象'definitiontypeform dtpropertylist'两次,这会导致不需要的行为。


对于你的问题在小提琴

我听不进去这里的按键声。我有一个jsfiddle的例子。如何在网格中的组合框编辑器上收听键盘?

在编辑器配置中添加您感兴趣的事件的侦听器,例如

listeners: {
    keydown: function(){
        // your code ...
    }
}

不要忘记为组合框启用Keyevents。

enableKeyEvents: true

完整的代码应该是

editor: {
        ...
        enableKeyEvents: true,
        listeners: {
            keydown: function(){
                // your code ...
            }
        }
    },

最新更新