【问题标题】:Sench Touch 2 - Rendering a ListSencha Touch 2 - 渲染列表
【发布时间】:2012-02-17 01:28:30
【问题描述】:

我有一个简单的 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')。 我错过了什么或做错了什么?

谢谢

【问题讨论】:

    标签: extjs sencha-touch


    【解决方案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>'
    
        }
    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      相关资源
      最近更新 更多