2
votes

Using a Sencha MVC example as a guide, I have created the following datastore:

Ext.define('CART.store.CartStore', {
extend: 'Ext.data.Store',
model: 'CART.model.CartModel',
autoLoad: true,
storeId: 'thecart',

proxy: {
    type: 'ajax',
    api: {
        read: 'app/testdata/items.json'
    },
    reader: {
        type: 'json',
        root: 'Items',
        successProperty: 'success'
    }
}
});

I have a Grid Panel defined that refers back to the datastore, as the following fragment shows:

Ext.define('CART.view.CartContents',{

extend: 'Ext.grid.Panel',

alias: 'widget.CartList',

title: 'Contents of Shopping Cart',

store: 'thecart',

...other stuff...

});

When I run my app without the CartContents' "store" attribute, the grid isplays without problems. Unfortunately, with "store" set to the ID of the datastore, I see the following failure when I run the app in Firebug:

Timestamp: 1/16/2013 9:19:08 PM

Error: TypeError: me.store is undefined

Source File: <my-url-to>/ext-all-debug.js

Line: 94926

Note I had to put in <my-url-to> because this posting app will not let me post this with the exact URL.

Obviously, the app is not finding the CartStore, despite the fact that, according to documentation and the info in the examples, it should.

Could someone tell me if I am missing anything? How can I make my Grid find the datastore?

Someone please advise.

UPDATE 1/17/2013: I took the advise provided in the two answers below (thanks for the quick responses). The new view object fragment is shown below:

Ext.define('CART.view.CartContents',{

extend: 'Ext.grid.Panel',

alias: 'widget.CartList',

requires: ['CART.store.CartStore'],

title: 'Contents of Shopping Cart',

store: 'CartStore',

...other stuff...

});

Unfortunately, I am still getting the same error. I did try flushing the cache, just in case the browser was not getting the updated page. This has had no effect either. me.store still appears undefined.

2

2 Answers

2
votes

ID property is not used to set the view store

try to replace this:

store: 'thecart',

to this:

store: 'CartStore',

and add requires

requires: ['CART.store.CartStore']

on view class

3
votes

Add the following to your custom cart component:

requires: ['CART.store.CartStore']