【问题标题】:sencha extjs run when storemanager has finished loading?sencha extjs 在 storemanager 完成加载后运行?
【发布时间】:2019-03-09 07:07:30
【问题描述】:

在开发应用程序时,我会在应用程序启动时运行一些代码:

Ext.application({
    extend: 'TestApp.Application',

    name: 'TestApp',

    requires: [
        'TestApp.*'
    ],

    // The name of the initial view to create.
    launch: async function () {
        const store_org = Ext.getStore('Organizations');
        const store_event = Ext.getStore('Events');
        //more stuff here
    }
});

两个商店的定义都很好:

Ext.define('TestApp.store.Organization', {
    extend: 'Ext.data.Store',
    storeId: 'Organizations',
    alias: 'store.organizations',

    model: 'TestApp.model.Organization',
    autoLoad: true,

    pageSize: 0,


    proxy: {
        type: 'ajax',
        url: TestApp.util.Config.getHost() + '/organization/get-organizations',
        withCredentials: true,
        reader: {
            type: 'json',
            rootProperty: '',
        },
    },
});

但是我确实注意到,在启动 Ext.getStore() 函数时,对于任何商店,总是返回 undefined。有什么办法可以将其“延迟”到 storemanager 已完全加载并且这些商店不再返回 undefined 的程度? (存储本身不会被数据填充......)。

【问题讨论】:

    标签: javascript extjs store extjs6-modern


    【解决方案1】:

    只需将其添加到 Ext.application 类或 TestApp.application (更好)

    stores:['TestApp.store.Organization'],
    

    这是你所有商店的数组,所以如果你需要添加更多,只需使用逗号并写下新文件的类路径名

    这是一个工作示例Fiddle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-13
      • 2015-02-12
      • 2014-03-08
      • 2014-01-08
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多