Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 如何在控制器中获得存储以将数据绑定到视图?_Extjs_Sencha Touch 2 - Fatal编程技术网

Extjs 如何在控制器中获得存储以将数据绑定到视图?

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

我有一个带有处理程序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);
},
...
}
试试这个代码

Ext.getStore('storeId')

它将为您提供store的对象

,但如何以及在何处定义“storeId”?xtype不会像我尝试的那样做。soterId是存储的配置,所以您可以在存储中定义storeId:'testStore'thx。我发现商店的名字也可以。因此,如果存储名为Contacts.js,则可以执行以下操作:Ext.getStore(“Contacts”);