Getting a loaded store in extjs4

I am getting null while I try to obtain a loaded store from the controller. 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(); which says it is an undefined function in controller.

Am I missing something over here?

Answers:

Answer

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.

So if you delete your storeId: 'schemedatastoreid' config then you will automatically get a storeId of schemedatastore. I don't normally give MVC stores a seperate storeId config so I don't know if it causes a conflict somewhere. I also don't normally give my stores an alias either, that might be causing the getStore function some difficulties too.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.