2012-06-19 13 views
0

我在建築師做了一個應用程序。我的店是這如何在按鈕點擊加載商店

Ext.define('MyApp.store.storeMain', { 
extend: 'Ext.data.Store', 
requires: [ 
    'MyApp.model.modelMain' 
], 

constructor: function(cfg) { 
    var me = this; 
    cfg = cfg || {}; 
    me.callParent([Ext.apply({ 
     autoLoad: false, 
     storeId: 'storeMain', 
     model: 'MyApp.model.modelMain', 
     pageSize: 50, 
     proxy: { 
      type: 'ajax', 
      reader: { 
       type: 'json', 
       root: 'Main', 
       totalProperty: 'Main.totalCount' 
      } 
     } 
    }, cfg)]); 
}}); 

這是我的按鈕:

{ 
           xtype: 'button', 
           text: 'Submit', 
           listeners: { 
            click: { 
             fn: me.onButtonClick, 
             scope: me 
            } 
           } 

,這是功能

onButtonClick: function(button, e, options) { 
    storeMain.load({ 
     url:'test.json' 
    }) 
} 
          }, 

但它不加載店。相反,它給出了這個錯誤:storeMain沒有被定義。我有一個viewport.js和其他文件,如storeMain.js

回答

1

任何地方都沒有變量storeMain。您需要致電Ext.getStore('storeMain')以獲得商店參考。