簡體   English   中英

extjs存儲代理不調用xtype

[英]extjs store proxy not invoking for xtype

我有一個彈出窗口,有一些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'的現有商店實例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所說,你必須使用一個excisting store實例,或者你可以使用一個配置。 然后,配置將導致為您內部創建的新商店實例。

要使用配置動態創建商店實例,您需要在商店類上提供別名,例如alias: "store.mystore" 現在,您可以在網格類的商店配置中引用它,例如store: { type: 'myStore' }

把它們放在一起下面,看看還有一個小提琴

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM