1
votes

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

    ]
});
2
are you sure the model is getting loaded in the file where the store definition is? Try changing the model name and check whether the error is still the same. And by the way, where are you creating the store? I see your definition, but I can't seem to find any Ext.create('RateManagement.store.CountrySpecificStore') or anything like that. - martskins
I added more code that shows where I am using the store and model and so fourth. Does this provide helpful insight into this problem? - user1477388
Can you provide a fiddle? I'm not sure about setting the store like you did, have you donde that before? Try with Ext.create('yourstore') instead - martskins
I have done that before and it works, it loads all my records from my database by accessing the proxy; however,my problem is it loads the wrong proxy when I use Ext.data.StoreManager.get("CountrySpecificStore"). I don't really know how to add a fiddle for extjs. - user1477388
Sencha fiddle is a good place to do that fiddle.sencha.com/#home :P - martskins

2 Answers

1
votes

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")

0
votes

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