Red Forman
Red Forman

Reputation: 33

extjs store proxy not invoking for xtype

I have a popup window that has some xtypes, one xtype is a grid and that has a Store but i dont see it invoking any ajax call. Can someone tell me what am i missing?

Ext.define('myApp.view.myPopup' {...
....
{
            xtype: 'grid',
            store: 'MyStore',
            iconCls: 'x-fa fa-users',
            height : 450,
            columns: [{
                header...

...}

Store

Ext.define('myApp.store.MyStore', {
    extend: 'Ext.data.Store', 
    model: 'myApp.model.modelA',
    pageSize: 100,
    remoteSort: true,
    autoload : true,
    proxy: {
        type: 'ajax',
        url : 'getStatusId',
        reader: {
            type: 'json',
            root: 'rows',
            successproperty: 'status',
            totalProperty: 'records'        
        }
    },
    listeners : {
        beforeload : function(store, operation, eOpts) {
            ...
            store.getProxy().extraParams = submitParams;
        }
    }

});

Upvotes: 3

Views: 307

Answers (3)

And-y
And-y

Reputation: 1524

Like @evan-trimboli states out you have to either use an excisting store instance or you can use a config. The config will then lead to a new store instance created for you internal.

To use a config to create a store instance on the fly, you need to provide an alias on the store class e.g. alias: "store.mystore". Now you can reference to it in the store config of the grid class like store: { type: 'myStore' }.

Bring it all together below and see also a running fiddle.

Ext.define('myApp.store.MyStore', {
    extend: 'Ext.data.Store',
    alias: 'store.mystore',  // the alias we need for the store config of the grid
    // ...
});

Ext.define('myApp.view.myPopup', {
    extend: 'Ext.grid.Panel',
    store: {
        type: 'mystore' // references the store by it's alias
    },
    // ...
};

Upvotes: 2

Anusha kurra
Anusha kurra

Reputation: 480

Create an instance of store and point to it.

 var store = Ext.create('myApp.store.MyStore' {
                autoLoad : true,        
            });
..........

    {       xtype: 'grid',
            store: store,
            iconCls: 'x-fa fa-users',
            height : 450,

    }

Upvotes: 2

Evan Trimboli
Evan Trimboli

Reputation: 30082

You have a typo: autoload -> autoLoad.

Your code also doesn't show an instance of the store being created. store: 'MyStore' requires an existing store instance with a storeId: 'MyStore'.

You probably want something more like:

Ext.define('myApp.view.myPopup' {...
....
{
            xtype: 'grid',
            store: { type: 'myStore' },
            iconCls: 'x-fa fa-users',
            height : 450,
            columns: [{
                header...

...}

Ext.define('myApp.store.MyStore', {
    extend: 'Ext.data.Store', 
    alias: 'store.myStore',
    model: 'myApp.model.modelA',
    // ....
});

Upvotes: 3

Related Questions