本文介绍了无法添加要存储在ExtJS Controller中的侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个工具栏中的按钮。如果我点击这个按钮打开一个窗口执行下面的代码:

In my application I have a button in a toolbar. If I click on this button to open a window following code is executed:

[...]
onClick: function() {
    this.windowControl = this.getController('attributesearch.Window');
    this.windowControl.init();
    this.windowControl.showWindow();
}
[...]

此窗口包含一些输入字段combobox with a store:

This window contains some inputfields and a combobox with a store:

Ext.define('EM.store.AttributeQuery', {
    requires: ['EM.model.AttributeQuery'],
    model: 'EM.model.AttributeQuery',
    proxy: {
        type: 'ajax',
        url: './app/configuration/AttributeQueries.json',
        reader: {
            type: 'json',
            root: 'queries'
        }
    },
    autoLoad: true
});



在我的窗口控制器的init方法中,我想添加一个 onLoad -listener
我尝试将此侦听器添加到商店:

Within the init method of my window controller I want to add one onLoad-listener
I try to add this listener to the store:

init: function() {
        this.getAttributeQueryStore().on('load', this.onStoreLoad, this);
        this.control({
            'attributeSearchWindow': {
                afterrender: this.onWindowRendered
            }
        });
    },

init方法的第一行 getAttributeQueryStore()。on('load',this.onStoreLoad,this); 产生以下错误:

The first line in the init method this.getAttributeQueryStore().on('load', this.onStoreLoad, this); produces the following error:


Uncaught TypeError: Object [object Object] has no method 'on' app/controller/attributesearch/Window.js:9.

看来商店不是完全(或正确)实例化。我缺少什么?

It seems the store is not fully (or correct) instantiated. What am I missing?

编辑

c $ c> this.getAttributeQueryStore()是这样的:

The console output for this.getAttributeQueryStore() is this:

constructor {self: function, superclass: Object, config: emptyFn, initConfigList: Array[0], initConfigMap: Object…}
__proto__: TemplateClass
$className: "EM.store.AttributeQuery"
autoLoad: true
config: emptyFn
configMap: TemplateClass
initConfigList: Array[0]
initConfigMap: Object
model: "EM.model.AttributeQuery"
proxy: Object
requires: Array[1]
self: function constructor() {
superclass: Object
__proto__: Object
}


推荐答案

这是我自己的错。

在我的商店定义,你会看到我忘了插入 extent:'Ext.store.Store'。而已。现在我可以添加和删除像我预期的侦听器。

If you have a closer look at my store definition, you will see that i forgot to insert the extent: 'Ext.store.Store'. Thats it. Now i can add and remove listeners like i expected to.

谢谢大家。

这篇关于无法添加要存储在ExtJS Controller中的侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:55