extjs 存储代理不为 xtype 调用

extjs store proxy not invoking for xtype

我有一个弹出窗口 window,它有一些 xtypes,一个 xtype 是一个网格并且有一个商店,但我没有看到它调用任何 ajax 调用。有人可以告诉我我错过了什么吗?

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

...}

商店

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;
        }
    }

});

您输入错误:autoload -> autoLoad

您的代码也没有显示正在创建的商店的实例。 store: 'MyStore' 需要具有 storeId: 'MyStore'.

的现有商店实例

您可能想要更多类似的东西:

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',
    // ....
});

创建一个存储实例并指向它。

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

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

    }

就像@evan-trimboli 指出的那样,您必须使用现有的商店实例或者您可以使用配置。然后,该配置将导致在内部为您创建一个新的商店实例。

要使用配置动态创建商店实例,您需要在商店上提供别名 class 例如alias: "store.mystore"。 现在您可以在网格 class 的商店配置中引用它,例如 store: { type: 'myStore' }.

在下面将所有内容放在一起,另请参阅 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
    },
    // ...
};