2012-08-28 65 views
0

我App.js的代碼在這裏:商店加載順序

Ext.Loader.setConfig({ 
    enabled: true 
}); 

Ext.application({ 
    name: 'KP', 
    appFolder: 'scripts/app', 

    controllers: [ 
     'MainSearch', 'List' 
    ], 

    launch: function() { 
     Ext.create('Ext.container.Viewport', { 
      items: { 
       xtype: 'searchdata' 
      } 
     }); 
    } 
}); 

的問題是: 我有模式( '列表'),存儲( '列表'),視圖( '列表')和控制器('列表') - 所有這些都是我的網格。在商店('列表')我打電話給服務,這給了我一些數據。

我想在「MainSearch」表單後查看我的網格。所以,我首先調用了「MainSearch」。 (在App.js中)。但是,在我的瀏覽器中顯示「MainSearch」表單之前,「List」中的服務被調用。我不明白爲什麼會發生。 (當App.js不包括 '列表' 控制器 - 一切工作正常)

「列表」 的 '商店' 代碼:

Ext.define('KP.store.List', { 

    extend: 'Ext.data.Store', 
    model: 'KP.model.List',   

    autoLoad: true, 

    pageSize: 20, 
    autoLoad: { start: 0, limit: 20 }, 


    autoSync: true, 
    proxy: { 
     type: 'ajax', 
     limitParam: 'size', 
     startParam: undefined, 
     api: { 

     read: '/adres/listls' 
     }, 
     reader: { 
      type: 'json', 
      root: 'data', 
      successProperty: 'success', 
      totalProperty: 'total' 
     }  
    } 

}); 

'列表' 控制器代碼:

Ext.define('KP.controller.List', { 

    extend: 'Ext.app.Controller', 

    views: ['personAccount.List'], 
    models: ['List'], 
    stores: ['List'], 

    init: function() { 
     this.control({ 
      'list button[action=close]': { 
       click: this.closeClick 
      } 
     }); 
    }, 

    //закрытие формы 
    closeClick: function (button) { 
     var win = button.up('window'); 
     win.close(); 
    } 

}); 

我的列表視圖代碼:

Ext.define('KP.view.personAccount.List', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.list', 

    autoScroll: true, 
    modal: false, 
    plain: false, 
    autoShow: true, 
    layout: { 
     type: 'fit' 
    }, 

    initComponent: function() { 
     var me = this; 
     Ext.applyIf(me, { 

      items: [ 
          { 
           xtype: 'gridpanel', 
           store: 'List', 

           forceFit: true, 
           columns: [ 
              .... 
             ], 

           dockedItems: [ 
               { 
                xtype: 'pagingtoolbar', 
                store: 'List', 
                dock: 'bottom',              
                displayInfo: true 
               } 

              ] 
          } 

        ] 
     }); 



     me.callParent(arguments); 
    } 

}); 

非常感謝!

+0

這是不是很清楚你問什麼,你需要發佈更多的信息。 –

+0

它一點也不清楚。 「這是問題」是最好的部分......哪個問題? – sra

+0

可能是由於initComponent:function()在Vew「List」中? – Oleg

回答

2

你需要做的是在你的商店中禁用autoLoad。這種方式存儲將被初始化,但它不會調用您的服務來獲取數據。稍後,您將在您的網格的afterrender處理程序中調用store.load()

+0

這是在您的商店deffinately autoLoad,使用 autoLoad:false。 您也可以在網格的initComponent中加載商店。 –

+0

這似乎是真的,但它並沒有幫助我(我添加了一個視圖代碼,可能你有一些想法? – Oleg

+0

我做到了!我還必須從我的商店刪除此代碼:autoLoad:{start:0,limit:20}謝謝你的建議! – Oleg