简体   繁体   English

在extjs4中获取加载的商店

[英]Getting a loaded store in extjs4

I am getting null while I try to obtain a loaded store from the controller. 当我尝试从控制器获取加载的存储时,我变为null。 The load is a successful one too. 负载也很成功。 I verified that. 我证实了这一点。

I have the store as follows. 我有如下商店。

Ext.define('GridApp.store.schemedatastore',{
    extend: 'Ext.data.Store',
    model: 'GridApp.model.schemedatamodel',
    autoLoad: true,
    alias: 'store.schemedata',
    storeId: 'schemedatastoreid',
    constructor:function(){
        console.log('Calling parent');
        this.callParent(arguments);
        },
    listeners: {
        load:function(store,records,isSuccessful){
            if(isSuccessful){
                console.log('Load successful');
            }
            console.log(records[0].get('name'));
            console.log('scheme Data store loaded too.');
        },
    }
});

In my controller I added like, 在我的控制器中我添加了喜欢,

stores: ['schemesstore',
             'schemedatastore'],

I tried accessing in these both ways in the controller, 我尝试在控制器中以这两种方式访问​​,

Ext.getStore('schemedatastoreid'); which returns null and this.getschemedatastoreStore(); 返回null和this.getschemedatastoreStore(); which says it is an undefined function in controller. 这说它是控制器中未定义的功能。

Am I missing something over here? 我在这里错过了一些东西吗?

Try any of these: 尝试以下任何一个:

this.getSchemedatastoreStore()

// the non-alias version of getStore    
Ext.StoreManager.lookup('schemedatastoreid') 

// in case MVC behavior overrides your storeId config
Ext.StoreManager.lookup('schemedatastore') 

MVC pattern will give your store the store class name as a store ID automatically if you don't define your own. 如果您没有定义自己的商店ID,MVC模式将自动为商店提供商店类名称作为商店ID。

So if you delete your storeId: 'schemedatastoreid' config then you will automatically get a storeId of schemedatastore . 因此,如果您删除storeId: 'schemedatastoreid'配置,那么您将自动获得schemedatastore的schemedatastore I don't normally give MVC stores a seperate storeId config so I don't know if it causes a conflict somewhere. 我通常不会给MVC商店一个单独的storeId配置,所以我不知道它是否会在某个地方引起冲突。 I also don't normally give my stores an alias either, that might be causing the getStore function some difficulties too. 我通常也不会给我的商店一个别名,这可能会导致getStore功能也有一些困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM