简体   繁体   中英

Accessing Ext Designer JsonStore from another file

I want to access an JsonStore created from the ext designer from another panels user js file. The file store file generated from the designer looks like this

myJsonStore = Ext.extend(Ext.data.JsonStore, {
 constructor: function(cfg) {
    cfg = cfg || {};
    CoaJsonStore.superclass.constructor.call(this, Ext.apply({
        storeId: 'myJsonStore',
        url: '/server.json',
        restful: true,
        autoLoad: true,
        autoSave: false,
        fields: [
            {
                name: 'id'
            },
            {
                name: 'code'
            },
            {
                name: 'name'
            }

        ]
    }, cfg));
}
});
new myJsonStore();

what i am doing right now is using a hidden combo and assign the store to the combo, this allows me to access it via autoRef (with. combo.getStore(), it gives me an object type of Store). Ideally i want to be able to do it without the hidden combo.

i have tried referring to it with storeId, but it doesn't work, if i log the storeId to the console this is what i get.

 function (cfg) {
    cfg = cfg || {};
    CoaJsonStore.superclass.constructor.call(this, Ext.apply({
        storeId: 'myJsonStore',
        url: '/coas.json',
        restful: true,
........

so i was just wondering whether this is even possible. if so some direction on how to get it done would be greatly appreciated . thanks

The new myJsonStore(); only creates a new store. In order to reference the store elsewhere in your code ( same file or another file) you need to use a variable. Create the store like this:

 var myStore = new myJsonStore();

And to bind it to the comobobox use the variable name myStore with the store property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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