English 中文(简体)
未从仓库中提取数据
原标题:Extjs Not Showing data from store

I`m learning Extjs and trying to follow this tutorial http://www.sencha.com/learn/the-mvc-application-architecture/ Everything went well.. But when I continue to Creating a Model and a Store and do as written in tutorial then run it. It give error : Uncaught TypeError: Cannot read property items of undefined Is there is something I missed up? Thank you

/app/ Controller/User.js

Ext.define( AM.controller.Users , {
    extend:  Ext.app.Controller ,
    stores: [
         Users ],
    models: [ User ],
    views: [
         user.List ,
         user.Edit ],
    init: function () {
        this.control({
             viewport > panel : {
                render: this.onPanelRendered
            },
             userlist : {
                itemdblclick: this.editUser
            }
        });
    },

    editUser: function (grid, record) {
        var view = Ext.widget( useredit );

        view.down( form ).loadRecord(record);
    },
    onPanelRendered: function () {
        console.log( panel rendered );
    }
})

/app/model/User.js

Ext.define( AM.model.User , {
    extend:  Ext.data.Model ,
    fields: [ name ,  email ]
});

/app/store/Users.js

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

    data: [
        {name:  Ed ,    email:  ed@sencha.com },
        {name:  Tommy , email:  tommy@sencha.com }
    ]
});

/app/view/user/Edit.js

Ext.define( AM.view.user.Edit , {
    extend:  Ext.window.Window ,
    alias :  widget.useredit ,

    title :  Edit User ,
    layout:  fit ,
    autoShow: true,

    initComponent: function() {
        this.items = [
            {
                xtype:  form ,
                items: [
                    {
                        xtype:  textfield ,
                        name :  name ,
                        fieldLabel:  Name 
                    },
                    {
                        xtype:  textfield ,
                        name :  email ,
                        fieldLabel:  Email 
                    }
                ]
            }
        ];

        this.buttons = [
            {
                text:  Save ,
                action:  save 
            },
            {
                text:  Cancel ,
                scope: this,
                handler: this.close
            }
        ];

        this.callParent(arguments);
    }
});

/app/view/user/List.js

Ext.define( AM.view.user.List ,{
    extend:  Ext.grid.Panel ,
    alias:  widget.userlist ,
    store:  Users ,
    title:  All users ,

});

/myapp.js

Ext.application({
    name:  AM ,

    controllers : [ Users ],
    appFolder:  app ,

    launch: function() {
        Ext.create( Ext.container.Viewport , {
            layout:  fit ,
            items: [
                {
                    xtype:  userlist ,
                }
            ]
        });
    }
});

/index.html

<!DOCTYPE HTML>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
        <script type="text/javascript" src="extjs/ext-debug.js"></script>
        <script type="text/javascript" src="myapp.js"></script>
    </head>
    <body>
        Loading apps.........
    </body>
</html>

Extjs library is located at /extjs

最佳回答

就像一个星号评论一样,在我的申请书中,以及在你名单上的所有用户档案中,在用户名单中,你还有额外的 com子。

此外,在关于该理论的评论中,也提到了一个类似问题,该决议涉及:

“List”观点界定了“columns”的财产

在你名单上添加:

columns: [
    {header:  Name ,  dataIndex:  name },
    {header:  Email , dataIndex:  email }
]
问题回答

Okay look like that you want to try the sencha mvc example @ examples/app/simple This example have a bug because the need to explicit load of Ext.container.Viewport on application launch

launch: function() {
        Ext.create( Ext.container.Viewport , { //this line do explicit load on Viewport class 

因此,为了解决这一难题,你需要在第1行的<条码>。

Ext.Loader.setConfig({enabled:true}); //need to enable dynamically load the Ext.container.Viewport
Ext.application({
    name:  AM ,

    //paths direct to the Ext src path folder i.e given here if accessed from http://localhost/ext/examples/app/simple/simple.html
    paths: {
         Ext :  ../../../src/  
    },
    controllers: [
         Users 
    ],
....




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签