Sencha Touch 2 - 渲染列表

时间:2012-01-23 17:35:40

标签: extjs sencha-touch

我有一个简单的MVC Sencha Touch应用程序,有1个商店,2个模型和2个视图 - 一个工具栏和一个列表。我的工具栏渲染得很好,但列表没有。没有例外,我找不到我做错了什么。

商店(Books.js):

Ext.define('App.store.Books', {
    extend: 'Ext.data.Store',
    model: 'App.model.Book',
    autoLoad: true,
    data: [
    { id: '1', name: '1984', publisher: 'Orwell' },
    { id: '2', name: 'Biography',  publisher: 'abcde' },
    { id: '3', name: 'The Old Man and the Sea',  publisher: 'Hemingway' }
    ]
});

视图(List.js - 我有另一个可以渲染的Bar.js):

Ext.define('App.view.List', {
    extend: 'Ext.List',
    store : 'Books',
    xtype : 'mylist',
    itemTpl: '<div><strong>Name: {name}</strong>Publisher: {publisher}</div>'
});

视口(Viewport.js) - 扩展了Ext.Container,正如我在几个例子中看到的那样:

Ext.define('App.view.Viewport', {
    extend: 'Ext.Container',
    requires : [
        'App.view.Bar',
        'App.view.List'
    ],
    config: {
        fullscreen: true,
        layout: 'fit',
        items: [
        {
            xtype : 'toolbar',
            docked: 'top'
        },
        {
            xtype: 'mylist'
        }
        ]
    }
});

正如我所写 - 我的工具栏显示,我的列表('mylist')不是。 我错过了什么或做错了什么?

由于

1 个答案:

答案 0 :(得分:1)

尝试在视图中添加配置

Ext.define('App.view.List', {

    extend:    'Ext.List',
    config:    {

        title:   'Books',
        cls:     'books',
        store:   'Books',
        itemTpl: '<div><strong>Name: {name}</strong>Publisher: {publisher}</div>'

    }

});
相关问题