user1477388
user1477388

Reputation: 21430

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'; consider adding Ext.require('CountrySpecific') above Ext.onReady

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

ext-dev.js:10587 Uncaught Error: [Ext.Loader] Failed loading synchronously via XHR: 'CountrySpecific.js'; please verify that the file exists. XHR status code: 404 ext-dev.js:10857

Instead of http://localhost/extjs/CountrySpecific.js?_dc=1395952634289 it should be calling my proxy which is defined as:

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?

Note: I am using 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.' }}

    ]
});

Upvotes: 1

Views: 1990

Answers (2)

user1477388
user1477388

Reputation: 21430

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();

Upvotes: 0

K..
K..

Reputation: 4223

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.

Since the only information he got is "CountrySpecificStore" he tries to find this class in the ExtJS directory.

You have to require the store class in the class that calls Ext.data.StoreManager.get("CountrySpecificStore")

Upvotes: 1

Related Questions