Extjs 如何在控制器中获得存储以将数据绑定到视图?
我有一个带有处理程序onLogin()的控制器,该处理程序在成功登录请求后被调用:Extjs 如何在控制器中获得存储以将数据绑定到视图?,extjs,sencha-touch-2,Extjs,Sencha Touch 2,我有一个带有处理程序onLogin()的控制器,该处理程序在成功登录请求后被调用: Ext.define('AddressBook.controller.Application', { extend: 'Ext.app.Controller', ... onLogin: function(form, record) { var editButton = this.getEditButton(); if (!this.showContact) { this.sho
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);
},
...
}
试试这个代码
Ext.getStore('storeId')
它将为您提供store的对象,但如何以及在何处定义“storeId”?xtype不会像我尝试的那样做。soterId是存储的配置,所以您可以在存储中定义storeId:'testStore'thx。我发现商店的名字也可以。因此,如果存储名为Contacts.js,则可以执行以下操作:Ext.getStore(“Contacts”);