Sencha触摸嵌套列表无数据 [英] Sencha touch nested list no data

查看:109
本文介绍了Sencha触摸嵌套列表无数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是sencha touch的新手.我用的是mvc方法.请在下面查看我的代码

I am new for sencha touch. I using mvc method. Please see my code below

Main.js

Ext.define('test.view.Main', {
    extend: 'Ext.tab.Panel',
    xtype: 'main',
    requires: [
        'Ext.TitleBar',
        'Ext.Video',
        'Ext.dataview.NestedList'
    ],
    config: {
        tabBarPosition: 'bottom',

        items: [
            {
                title: 'Welcome',
                iconCls: 'home',

                styleHtmlContent: true,
                scrollable: true,

                items: {
                    docked: 'top',
                    xtype: 'titlebar',
                    title: 'Welcome to Sencha Touch 2'
                },

                html: [
                    "You've just generated a new Sencha Touch 2 project. What you're looking at right now is the ",
                    "contents of <a target='_blank' href=\"app/view/Main.js\">app/view/Main.js</a> - edit that file ",
                    "and refresh to change what's rendered here."
                ].join("")
            },
            {




                title: 'Get Started',
                iconCls: 'action',

                items: [
                    {
                        docked: 'top',
                        xtype: 'titlebar',
                        title: 'Getting Started'
                    },
                    {
                        xtype: 'nestedlist',

                    }
                ]
            }
        ]
    }
});

Nestedlist.js

Nestedlist.js

 Ext.define('bluebutton.view.NestedList', {
    extend: 'Ext.NestedList',
    xtype: 'nestedlist',
    requires: [
        'Ext.field.Select',
        'Ext.field.Search',

        'Ext.plugin.ListPaging',
        'Ext.plugin.PullRefresh',



    ],
    config: {

          store : { xclass : 'Test.store.data'},
        detailContainer: detailContainer,
        detailCard: true,



    },


});

Test.store.data

Test.store.data

Ext.define('Test.store.data', {
    extend: 'Ext.data.TreeStore',

    config: {
        model: 'Test.model.data',
        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 }
                ]
            }
        ]
        }
    }
});

model.js

    Ext.define('Test.model.data', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['text']
    }



});

但是嵌套列表无法获取数据.我得到空名单.有什么办法吗?

But nested list no able to get the data. I get empty list. Any solution?

推荐答案

如果要在存储区中提供内联数据,应该不是data属性而不是root?

If you are providing inline data in store shouldn't it be data attribute instead of root?

Ext.define('Test.store.data', {
    extend: 'Ext.data.TreeStore',

    config: {
        model: 'Test.model.data',
        defaultRootProperty: 'items',
        data: {
            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 }
                ]
            }
        ]
        }
    }
});

这篇关于Sencha触摸嵌套列表无数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆