0

我正在尝试将现有应用程序从 ExtJs 4.2.1 移植到 6.0.1 在调试器中我看到网格有“ ext-empty-store ”存储而不是“store.accounting.Quota”的问题我可以直接加载存储在面板激活监听器中通过 var store = Ext.data.StoreManager.lookup('QuotaKPI.store.accounting.Quota'); 存储.load(); 在萤火虫中,我看到请求和完美的 json 作为响应,但网格中没有出现任何内容

以下是代码片段

应用/商店/会计/Quota.js

Ext.define('QuotaKPI.store.accounting.Quota', {
    extend: 'Ext.data.JsonStore',
    model: 'QuotaKPI.model.accounting.QuotaModel',
    alias: 'store.accounting.Quota',
    storeId: 'QuotaKPI.store.accounting.Quota',
    autoLoad: false,
    proxy: {
        ...
    }
});

应用程序/视图/会计/QuotaGrid.js

Ext.define('QuotaKPI.view.accounting.QuotaGrid', {
    extend: 'Ext.grid.Panel'
    ,xtype: 'QuotaGrid'
    ,store: Ext.data.StoreManager.lookup('QuotaKPI.store.accounting.Quota')

    ,columns: [ 
    ...
    ]

    ,dockedItems : [
                   ,{xtype: 'pagingtoolbar', 
                    dock:'bottom',
            store: Ext.data.StoreManager.lookup('QuotaKPI.store.accounting.Quota'),
            displayInfo: true,
            displayMsg: 'Displaying Quota Details {0} - {1} of {2}',
            emptyMsg: "No Quota to display"
            }
                   ]
    ,initComponent: function() {
            this.callParent(arguments);
        }       
   });

在控制器中声明的存储、模型和网格

Ext.define('QuotaKPI.controller.accounting.AccountingController', {
    extend: 'Ext.app.Controller',
    stores: ['accounting.Quota'],
    models: ['accounting.QuotaModel'],
    views: ['accounting.QuotaGrid']
    ...

控制器本身在 app.js 中列出

Ext.application({
    name: 'QuotaKPI',
    controllers: [
        'accounting.AccountingController'
    ],
    init: function(app){
    },
    autoCreateViewport: true
});

请问有什么帮助吗?

4

1 回答 1

1

I know storeId doesn't accept some character (for example "-"), I don't know for dot... in any case I suggest to make it simple. Try "myStoreId"

In addition you can try:

Ext.define('QuotaKPI.view.accounting.QuotaGrid', {
    extend: 'Ext.grid.Panel'
    ,xtype: 'QuotaGrid'
    ,store: "myStoreId",

    ,columns: [ 
    ...
    ]

    ,dockedItems : [
                   ,{xtype: 'pagingtoolbar', 
                    dock:'bottom',
            store: "myStoreId",
            displayInfo: true,
            displayMsg: 'Displaying Quota Details {0} - {1} of {2}',
            emptyMsg: "No Quota to display"
            }
                   ]
    ,initComponent: function() {
            this.callParent(arguments);
        }       
   });

In addition I suggest to ensure you have a proper schema configuration (see http://docs.sencha.com/extjs/6.0/6.0.1-classic/#!/api/Ext.data.schema.Schema)

And then, you could try also with ViewModel instead of storeId (see http://docs.sencha.com/extjs/5.0/application_architecture/view_models_data_binding.html)

Don't hesitate to do a https://fiddle.sencha.com/#home

Good Luck! Transition is not easy...

于 2015-11-16T20:54:56.770 回答