ExtJS商店未从代理加载

时间:2014-03-27 20:42:12

标签: javascript extjs

我的代码如下(我可以发布更多内容,如果它可以帮助你帮助我!):

//var store = myGrid.getStore();
var store = Ext.data.StoreManager.get("CountrySpecificStore")
console.log(store);

控制台在执行上述行时给我这个:

  

[Ext.Loader]同步加载' CountrySpecific&#39 ;;考虑添加   Ext.require(' CountrySpecific')在Ext.onReady

之上      

ext-dev.js:8894 GET   [localhost] /extjs/CountrySpecific.js?_dc=1395952634289 404(不是   实测值)

     

ext-dev.js:10587未捕获错误:[Ext.Loader]加载失败   同步通过XHR:' CountrySpecific.js&#39 ;;请验证   文件已存在。 XHR状态代码:404 ext-dev.js:10857

而不是http://localhost/extjs/CountrySpecific.js?_dc=1395952634289它应该调用我的代理,定义为:

Ext.define('RateManagement.store.CountrySpecificStore', {
    extend: 'Ext.data.Store',
    model: 'RateManagement.model.CountrySpecific',
    proxy: {
        type: 'rest',
        format: 'json',
        url: '/intake/sap/rates/CountrySpecific'
    },
    autoSync: true,
    autoLoad: true   
});

如何拨打电话http://localhost/intake/sap/rates/CountrySpecific

注意:我使用的是ExtJS 4.2.1。

编辑:这是我的网格,我正在使用商店:

Ext.define('RateManagement.view.Grids.CountrySpecificGrid', {
    extend: 'Ext.grid.Panel',
    requires:['Ext.ux.CheckColumn'],
    xtype: 'CountrySpecificGrid',
    store: 'RateManagement.store.CountrySpecificStore',
    plugins: [{
        clicksToMoveEditor: 1,
        autoCancel: false,
        ptype: 'rowediting',
        pluginId: 'rowediting'
    }],
    tbar: [{
            text: 'Add Rate',
            handler: function(button) {
                var myGrid = button.up('grid');
                //console.log(myGrid);
                var myPlugin = myGrid.getPlugin('rowediting');
                myPlugin.cancelEdit();

                var r = Ext.create('CountrySpecific', {
                    id: '',
                    hostCountryId: '',
                    hostCountry: '',
                    rate: 0,
                    currencyId: '',
                    rateTypeId: '',
                    frequencyCode: '',
                    perFamilyMember: '',
                    familySize: 0
                });

                //var store = myGrid.getStore();
                var store = Ext.data.StoreManager.get("CountrySpecificStore")
                console.log(store);

                // todo: create guid and add to store
                store.insert(0, r);
                myPlugin.startEdit(0, 0);
            }
        }],
    features: [{
        ftype: 'filters',
        encode: false,
        local: true,
        filters: [
            { type: 'string', dataIndex:'hostCountry' },
            { type: 'numeric', dataIndex:'rate' },
            { type: 'string', dataIndex:'currencyId' }

        ]
    }],
    columns: [
        {text: 'Host Country', dataIndex: 'hostCountry', width:150},
        {text: 'Rate', dataIndex: 'rate', xtype: 'numbercolumn',
            editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, blankText: 'Rate is required.', invalidText: 'Rate must be positive.' }},
        {text: 'Rate Currency', dataIndex: 'currencyId', xtype: 'currency-column' },
        {text: 'Frequency', xtype: 'rate-type-column' },
        {text: 'PerFamilyMember', dataIndex: 'perFamilyMember', xtype: 'checkcolumn',
            editor: {xtype: 'checkbox',cls: 'x-grid-checkheader-editor'}},
        {text: 'Family Size', dataIndex: 'familySize', 
            editor: { xtype: 'numberfield', minValue: 0,  invalidText: 'Family Size must be positive.' }}

    ]
});

2 个答案:

答案 0 :(得分:1)

您似乎正在使用StoreManager来获取之前尚未注册的商店,因此他尝试动态加载定义。

由于他获得的唯一信息是“CountrySpecificStore”,他试图在ExtJS目录中找到这个类。

您必须要求调用Ext.data.StoreManager.get("CountrySpecificStore")

的班级中的商店类

答案 1 :(得分:0)

我的问题是我需要像这样声明我的模型变量:

var r = Ext.create('RateManagement.model.CountrySpecific', {
    id: '',
    hostCountryId: '',
    hostCountry: '',
    rate: 0,
    currencyId: '',
    rateTypeId: '',
    frequencyCode: '',
    perFamilyMember: '',
    familySize: 0
});

然后,我能够简单地说:

var store = myGrid.getStore();