English 中文(简体)
包括数据 仓库使装料不装载
原标题:Including a data Store makes the app not load
  • 时间:2011-11-20 21:13:23
  •  标签:
  • extjs
  • extjs4

我可以不申请利用MVC建筑。

该守则是:

app.js

Ext.application({
    name: CONFIG.APP_NS,
    appFolder:  ../js/app ,
    autoCreateViewport: true,

    /*
    models: [ User ],

    stores: [ Users ],
    //*/

    controllers: [ Main ,  Tab ,  Import ,  Export ,  Predict ,  Admin ]  
});

Import.js (controller)

Ext.define(CONFIG.APP_NS+ .controller.Import , {
    extend:  Ext.app.Controller ,

    //stores: [ Users ], //Uncommenting this makes the application not load at all
    models: [ User ],
    views: [ Import.Window ,  Import.Toolbar ,  Import.Grid ],

    init: function(){
        ...
    },

    ...
});

User.js (model)

Ext.define(CONFIG.APP_NS+ .model.User , {
    extend:  Ext.data.Model ,
    fields: [
        {name:  id ,            type:  int },
        {name:  username ,      type:  string },
        {name:  password ,      type:  string },
        {name:  salt ,          type:  string },
        {name:  firstName ,     type:  string },
        {name:  lastName ,      type:  string },
        {name:  email ,         type:  string },
        {name:  admin ,         type:  boolean },
        {name:  authenticated , type:  boolean }
    ],

    hasMany: {model: CONFIG.APP_NS+ .model.Roles , name:  roles },

    proxy: {
        type:  ajax ,
        url:  model/users ,
        reader: {
            type:  json 
        }
    }
});

Ext.define(CONFIG.APP_NS+ .model.Roles , {
    extend:  Ext.data.Model ,

    fields: [
        {name:  role ,          type:  string }
    ],

    belongsTo: CONFIG.APP_NS+ .model.User 
});

Users.js (store)

Ext.define(CONFIG.APP_NS+ store.Users , {
    extend:  Ext.data.Store ,
    requires: CONFIG.APP_NS+ .model.User ,
    model: CONFIG.APP_NS+ .model.User 
});

Grid.js (view)

Ext.define(CONFIG.APP_NS+ .view.Import.Grid , {
    extend:  Ext.grid.Panel ,
    alias:  widget.importgrid ,

    initComponent: function() {
        this.store = Ext.create( Ext.data.Store , { //Works fine with the code as it is
            model: CONFIG.APP_NS+ .model.User ,
            proxy: {
                type:  ajax ,
                url:  model/users ,
                reader: {
                    type:  json 
                }
            }
        });
        //*/
        //this.store = Ext.create(CONFIG.APP_NS+ .store.Users , {});

        this.columns = [
            {header:  Name ,  dataIndex:  username ,  flex: 1},
            {header:  Email , dataIndex:  email , flex: 1}
        ];

        this.callParent(arguments);

        this.store.load();
    }
});

我尝试了几乎每一种组合的stores:,在不同可能的档案中,看不到什么。 如果我不把仓库列入任何地方,我就错了。 反对意见不是职能(或TypeError:如果在initComponent外定义,则在内部卷宗中有些地方使用未界定的<>/em>方法。 看来,即使我从理论例子中复制结构,它仍然不可行,因此我必须失踪。

我做了什么错误?

感谢你时间。

EDITS:

我正在Wamp(当地人)实施这一法典。 该服务器既有ExtJS4,也有安装和运行的同义词。

最新错误信息。

《示范法》中的固定字体见评论意见。

最佳回答

我看到了ug。

Users.js (store)

Ext.define(CONFIG.APP_NS+ store.Users , {
    extend:  Ext.data.Store ,
    requires: CONFIG.APP_NS+ .model.User ,
    model: CONFIG.APP_NS+ .model.User 
});

第一行应为:

Ext.define(CONFIG.APP_NS+ .store.Users , {

store之前,我失踪了一段时间。

Molecule Man的评论让我重述所有定义,感谢你。

问题回答

(见您的仓库在 app中做了评论。) 这是否有意?

我也遇到了类似的问题,一俟我把仓库添加到我的手头和观点中。 js(一个电网小组),我的 app停止工作。

我确信,我通过将库存(全部)添加到控制器来确定。 页: 1 Ok.刚刚再次检查,如果该仓库从控制器中消失,我会收到不同的错误信息:“独断型号:不使用未界定的方法”(这在hr)。 错误信息略有不同。

此外,还考虑发表评论。 i.e. 删除服务器数据存取变量(当时有一件事)





相关问题
ExtJS load form items/fields from database

I am using ExtJS 3 here. I would like to populate a formpanel from database with fields to be submitted. Basically, I don t know witch fields my form will have and I want to generate all formpanel ...

How to use Ext JS for role based application

I am planning to use Ext JS for a large application. The application s features are role based. When user login, they only see menu and screen features related to them. My server side technology will ...

Dynamically adding a TabPanel to a Panel Region

I have a Panel layout with a TreePanel in one region. A user clicks on an node in the tree and a TabPanel should be displayed in another region with information, editing tools etc. for that tree node....

How to embed Json result within Extjs Panel?

I have some issues with Json result and embed it within the html of the Extjs Panel. Here s that I have managed to get so far. myPanel is embedded within a mainPanel, and I have some shows/hide of ...

Ajax data update. Extjs

I need to keep certain data ( in a grid) up to date and was gonna do a poll to the server every 15 seocnds or so to get the data and refresh the grid, however it feels a bit dirty ( the grid will have ...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel ...

Merged Headers in Ext JS Grid

Is it possible to have two headers in Ext JS grids? I have to show my grid as grouped data.. for example product types and products. In my case I need a grid like this: Field | Product Type A ...

热门标签