简体   繁体   English

ExtJS存储未从代理加载

[英]ExtJS Store Not Loading From Proxy

My code is as follows (I can post more if it would help you help me!): 我的代码如下(如果可以帮助您,我可以发布更多信息!):

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

The console gives me this upon execution of the lines above: 控制台在执行以上各行后为我提供了此功能:

[Ext.Loader] Synchronously loading 'CountrySpecific'; [Ext.Loader]同步加载“ CountrySpecific”; consider adding Ext.require('CountrySpecific') above Ext.onReady 考虑在Ext.onReady之上添加Ext.require('CountrySpecific')

ext-dev.js:8894 GET [localhost]/extjs/CountrySpecific.js?_dc=1395952634289 404 (Not Found) ext-dev.js:8894 GET [localhost] /extjs/CountrySpecific.js?_dc=1395952634289 404(未找到)

ext-dev.js:10587 Uncaught Error: [Ext.Loader] Failed loading synchronously via XHR: 'CountrySpecific.js'; ext-dev.js:10587未捕获的错误:[Ext.Loader]无法通过XHR同步加载:'CountrySpecific.js'; please verify that the file exists. 请验证文件是否存在。 XHR status code: 404 ext-dev.js:10857 XHR状态码:404 ext-dev.js:10857

Instead of http://localhost/extjs/CountrySpecific.js?_dc=1395952634289 it should be calling my proxy which is defined as: 而不是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   
});

How can I make it call http://localhost/intake/sap/rates/CountrySpecific ? 我如何将其称为http://localhost/intake/sap/rates/CountrySpecific

Note: I am using ExtJS 4.2.1. 注意:我正在使用ExtJS 4.2.1。

Edit: Here is my Grid, where I am using using the store: 编辑:这是我使用存储的网格,在其中:

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.' }}

    ]
});

It seems like you're using the StoreManager to get a store, which hasn't been registered before, so he tries to dynamically load the definition. 似乎您正在使用StoreManager来获取商店,该商店之前尚未注册,因此他尝试动态加载定义。

Since the only information he got is "CountrySpecificStore" he tries to find this class in the ExtJS directory. 由于他获得的唯一信息是“ CountrySpecificStore”,因此他尝试在ExtJS目录中找到此类。

You have to require the store class in the class that calls Ext.data.StoreManager.get("CountrySpecificStore") 您必须在调用Ext.data.StoreManager.get("CountrySpecificStore")类中需要store类

My problem was I needed to declare my model variable like this: 我的问题是我需要这样声明模型变量:

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

Then, I was able to simply: 然后,我能够简单地:

var store = myGrid.getStore();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM