2014-01-31 48 views
1

明確實例化一個商店,我有鑑於這樣的:誤差鑑於

Ext.define('MyApp.view.CustomersList', { 
    extend: 'Ext.grid.Panel', 

    store: Ext.create('MyApp.store.Customers'), 

    columns: [ 
     { 
      width: 150, 
      dataIndex: 'customerName', 
      text: 'CustomerName' 
     }, 
     { 
      width: 200, 
      dataIndex: 'customerNumber', 
      flex: 1, 
      text: 'CustomerNumber' 
     } 
    ] 
}); 

我實例化一個商店明確,但是當我加載在視口中這個觀點,我覺得這樣的錯誤:

Uncaught TypeError: Expecting a function in instanceof check, but got function constructor() { 
     // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to 
     // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61. 
     return this.constructor.apply(this, arguments) || null; 
    } 

Uncaught TypeError: Expecting a function in instanceof check, but got function constructor() { 
     // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to 
     // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61. 
     return this.constructor.apply(this, arguments) || null; 
    } 

回答

2
Ext.define('MyApp.view.CustomersList', { 
     extend: 'Ext.grid.Panel', 

     initComponent: function(){ 
     this.store = Ext.create('MyApp.store.Customers'); 

     this.columns = [ 
     { 
     width: 150, 
     dataIndex: 'customerName', 
     text: 'CustomerName' 
     }, 
     { 
     width: 200, 
     dataIndex: 'customerNumber', 
     flex: 1, 
     text: 'CustomerNumber' 
     }] 
    this.callParent(); 
    } 
    }); 

希望它有幫助!

+0

感謝您的幫助,我很感激。這門課很好,沒有錯誤。但是,當我從控制器調用{store} .load()方法時,商店不會加載數據,因此網格爲空。我所做的解決這個問題的方法是在app.js中添加'MyApp.store.Customers'需要配置。 –

+0

很高興幫助!我建議在視圖之外的獨立文件中創建商店。您可以提供一些有助於識別問題的更多細節或代碼示例。 – Rajinder