Extjs Chained store for GlobalStore in ViewModel

I want to use a store linked in the global store, but after running I am warning js:

Ext.data.Store created with no model

      

and I don't see any data.

Here is my code:

Global custom directory

Ext.define('App.store.UserStore',{
extend      : 'App.store.AjaxReadyStore',
requires    : ['App.model.UserModel'],
model       : 'App.model.UserModel',
autoLoad    : false,
id          : 'UserStore',
alias       : 'store.UserStore',


constructor : function() {
    this.callParent(arguments);
    this.proxy.api= {
        create  : 'api/v1/users',
        read    : 'api/v1/users',
        update  : 'api/v1/users',
        destroy : 'api/v1/users'
    };
    this.readAndLoad();
}
});

      

ViewModel

Ext.define('App.view.tasktemplate.TaskTemplateModel', {
    extend  : 'Ext.app.ViewModel',
    alias   : 'viewmodel.tasktemplate',
    stores : {
        owner: {
            source  : 'UserStore'
        }
    }
});

      

View

Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
    extend  : 'App.view.pool.grid.GridWithAction',
    xtype   : 'tasktemplateownerlist',
    store: {
        bind : '{owner}'
    },
});

      

+3


source to share


1 answer


Change your view code to this -

Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
        extend  : 'App.view.pool.grid.GridWithAction',
        xtype   : 'tasktemplateownerlist',
        bind: {
            store : '{owner}'
        }
    });

      

Saving the binding:

bind: {
     store : '{owner}'
}

      



It is really interesting when you do

store: {
        bind : '{owner}'
    }

      

inside your view. StoreManager searches with a store config value, usually expecting a string or an array of strings (store name), but it sees that it is not a string, but an object, so it instantiates' Ext.data.Store 'passes {bind:' {owner} '} as config -> so you actually end up with an instance of the Store class with no bound models. score:

0


source







All Articles