2012-09-24 65 views
1

我有一個處理onLogin()的獲取請求成功登錄後稱爲控制器:如何獲取控制器中的存儲以將數據綁定到視圖?

Ext.define('AddressBook.controller.Application', { 
extend: 'Ext.app.Controller', 
... 
onLogin: function(form, record) { 
    var editButton = this.getEditButton(); 

    if (!this.showContact) { 
     this.showContact = Ext.create('AddressBook.view.contact.Show'); 
    } 

    //how to get this store? 
    var store = getContactsStore(); 
    //how to get the data in the store or should I get the model? 
    this.showContacts.updateDataProvider(store.array); 

    // Push the show contact view into the navigation view 
    this.getMain().push(this.showContact); 
}, 
... 
} 

回答

2

試試這個代碼

Ext.getStore('storeId') 

它會給你店裏的對象

+0

但如何我在哪裏定義'storeId'? xtype不會按我的方式做。 –

+0

soterId是商店的配置,因此您可以在商店中定義storeId:'testStore' –

+0

thx。我發現商店的名字也會這樣。所以如果商店被稱爲Contacts.js,你可以這樣做:Ext.getStore(「Contacts」); –

相關問題