2013-08-16 55 views
1

在我的應用程序中,我在工具欄中有一個按鈕。如果我單擊此按鈕打開一個窗口下面的代碼被執行:無法添加偵聽器以存儲在ExtJS控制器中

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

該窗口包含一些inputfields與商店的組合框:在我的窗口控制我的init方法

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 
});

要添加一個的onLoad監聽
我嘗試這個監聽器添加到店:

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

第一李ne在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 
}
+0

支票控制檯'store',大概'store'是無法訪問 – MMT

+0

editet爲CONSOLE.LOG到我的問題的答覆。商店是東西,但似乎沒有像我期望的那樣被實例化(不管它可能是什麼)。我無法找到'on','addListener'或ExtJS文檔向我展示的任何其他方法。 – semTex

+0

嘗試在呈現事件後在窗口上綁定'store load'事件 – MMT

回答

-1

這是我自己的錯。

如果你有在我的商店定義仔細看看,你會看到,我忘了插入。而已。現在我可以像我期望的那樣添加和刪除監聽器。

謝謝大家。

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); 
     } 
    } 
}); 
+0

你好Towler能請你分享它的文檔。那對你很好。謝謝 – Gardezi

相關問題