liam xu
liam xu

Reputation: 3030

extjs4 TypeError: store is undefined

I am a newbie for extjs4. I am reading the application architecture in the extjs offical website which offered a simple example(application_architecture). But I encountered some issues when studying this case.

enter image description here

The app sturcture in eclipse is like above. The question I met is regarding the store.

app\controller\Users.js please look at the comment in this piece of code.

Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',
    stores: [
        'AM.store.Users'  //this line of code can't work, unless I update it to `Users`
                          //or it will report the exception 'TypeError: store is undefined'
    ],
    models: [
        'AM.model.User'
    ],

Now I pasted the code of the other files related to this issue.

app\store\Users.js

Ext.define('AM.store.Users', {
    extend: 'Ext.data.Store',
    model: 'AM.model.User',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        api: {
            read: 'data/users.json',
            update: 'data/updateUsers.json'
        },
        reader: {
            type: 'json',
            root: 'users',
            successProperty: 'success'
        }
    }
});

I have searched for the exception in google, but got nothing helpful, and I have debugged it in firefox, still nothing, maybe because I am an expert in javascript. I also checked the source code of other extjs apps in the company I worked, I found the controller can refer to the store like 'AM.store.Users'

Thanks in advance!

Upvotes: 0

Views: 3054

Answers (2)

Artem Kozlenkov
Artem Kozlenkov

Reputation: 1254

app.js shouldn't be modified with significant logic as it will be rewritten on every framework update

Upvotes: 0

Sreek521
Sreek521

Reputation: 669

I think you can refer your store as 'AM.store.Users' by adding an entry in your app.js config for stores like below similar to controllers.

stores:['Users']

Please try it once,hope it will help you.

Upvotes: 1

Related Questions