Sencha Touch 2:在TabPanel中添加NestedList

时间:2013-12-24 16:08:41

标签: sencha-touch-2

我尝试在TabPanel中插入NestedList,但是我得到一个空列表,不显示内容。如何使这个嵌套列表可见

我试过的代码:

提前感谢您的帮助

Ext.define('ListItem', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['text']
    }
});

var treeStore = Ext.create('Ext.data.TreeStore', {
    model: 'ListItem',
    defaultRootProperty: 'items',
    root: {
        items: [
            {
                text: 'Drinks',
                items: [
                    {
                        text: 'Water',
                        items: [
                            { text: 'Still', leaf: true },
                            { text: 'Sparkling', leaf: true }
                        ]
                    },
                    { text: 'Soda', leaf: true }
                ]
            },
            {
                text: 'Snacks',
                items: [
                    { text: 'Nuts', leaf: true },
                    { text: 'Pretzels', leaf: true },
                    { text: 'Wasabi Peas', leaf: true  }
                ]
            }
        ]
    }
});

Ext.create('Ext.NestedList', {
    fullscreen: true,
    store: treeStore
});

Ext.application({
    name: 'Sencha',

    launch: function() {
        // The whole app UI lives in this tab panel
        Ext.Viewport.add({
            requires: ['Ext.List', 'Ext.dataview.List', 'Ext.data.proxy.JsonP'],
            xtype: 'tabpanel',
            fullscreen: true,
            tabBarPosition: 'bottom',

            items: [
                // This is the recent blogs page. It uses a tree store to load its data from blog.json.
                {
                    xtype: 'nestedlist',
                    title: 'Blog',
                    iconCls: 'star',
                    cls: 'blog',
                    displayField: 'title',
                    store: treeStore
                }
            ]
        });
    }
});

1 个答案:

答案 0 :(得分:0)

在您提供的代码的底部,在您创建的嵌套列表中,您要设置一个值为“title”的 displayfield 属性。因此,列表尝试使用模型中的“标题”字段,该字段不存在。您可以更改商店数据以使用“标题”而不是“文字”,或删除 displayField 属性(默认情况下已经是“文字”)。

相关问题