jaffa
jaffa

Reputation: 27350

Store needs to have a model defined on either itself or on its proxy

When I do this in a console window:

var s = new Ext.data.Store('MyApp.store.Genders');

I get the following error:

Unless you define your model through metadata, a store needs to have a model defined on either itself or on its proxy

However my store actually has a model defined on it:

Ext.define('MyApp.store.Genders', {
    extend: 'Ext.data.Store',

    requires: [
        'MyApp.model.Lookup',        
        'Ext.data.proxy.Rest'
    ],

    config: {
        autoLoad: true,
        model: 'MyApp.model.Lookup',
        storeId: 'GenderStore',
        proxy: {
            type: 'rest',            
            url : '/api/lookup/genders',
            reader: {
                type: 'json'
            }
        }
    }    
});

Any reason why this isn't working correctly?

Upvotes: 3

Views: 1153

Answers (1)

SashaZd
SashaZd

Reputation: 3319

may I ask why you're creating a new store object ? When you use Ext.define, you are technically already creating a Store object in Sencha that you can use to store all your data. Why do you need to create the

var s =

Basically, when you created the Ext.define('StoreName',{params_with_Model}) you created a store object, with an associated model called StoreName. However, you haven't registered this as an xtype, that you can then make objects from later (in fact I'm not even sure you can do that).

However, when you created a new variable s, in Sencha, you didn't create a object of Store type 'StoreName'. Instead, you tried to create a second store with the same name. And this is totally unrelated to the first, so Sencha expected you to provide a model, and data as you normally would in the Ext.define.

Upvotes: 1

Related Questions