1

私のアプリケーションでは、ツールバーにボタンがあります。このボタンをクリックしてウィンドウを開くと、次のコードが実行されます。

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

このウィンドウには、いくつかの入力フィールドとストアのあるコンボボックスが含まれています。

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 メソッド内で、1 つのonLoad-listenerを追加したいので
、このリスナーをストアに追加しようとします。

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

init メソッドの最初の行でthis.getAttributeQueryStore().on('load', this.onStoreLoad, this);、次のエラーが発生します。

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

ストアが完全に (または正しく) インスタンス化されていないようです。私は何が欠けていますか?

編集:

のコンソール出力this.getAttributeQueryStore()は次のとおりです。

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
}
4

2 に答える 2

0

ストアのリスナーをストアの定義の一部として定義してみませんか?

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,
    listeners: {
       load: function(store, records, options) {
          EM.getApplication().getController('attributesearch.Window').onStoreLoad(store, records, options);
       }
    }
});
于 2013-08-20T00:46:04.077 に答える
-1

それは私自身のせいです。

ストアの定義をよく見ると、extent: 'Ext.store.Store'. それでおしまい。これで、期待どおりにリスナーを追加および削除できます。

みんなありがとう。

于 2013-08-21T12:30:13.317 に答える