【问题标题】:how load a store on button click如何在按钮单击时加载商店
【发布时间】:2012-06-21 08:36:59
【问题描述】:

我在建筑师中制作了一个应用程序。我的店是这个

Ext.define('MyApp.store.storeMain', {
extend: 'Ext.data.Store',
requires: [
    'MyApp.model.modelMain'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: false,
        storeId: 'storeMain',
        model: 'MyApp.model.modelMain',
        pageSize: 50,
        proxy: {
            type: 'ajax',
            reader: {
                type: 'json',
                root: 'Main',
                totalProperty: 'Main.totalCount'
            }
        }
    }, cfg)]);
}});

这是我的按钮:

{
                                xtype: 'button',
                                text: 'Submit',
                                listeners: {
                                    click: {
                                        fn: me.onButtonClick,
                                        scope: me
                                    }
                                }

这就是函数

onButtonClick: function(button, e, options) {
    storeMain.load({
        url:'test.json'
    })
}
                            },

但它没有加载商店。相反,它给出了这个错误:未定义 storeMain。我有 viewport.js 和其他文件,例如 storeMain.js

【问题讨论】:

    标签: extjs load store


    【解决方案1】:

    在任何地方都没有变量storeMain。您需要致电Ext.getStore('storeMain') 获取店铺参考信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多