Sencha Touch - In need of a nested list example

自古美人都是妖i 提交于 2019-12-04 08:17:53

you should look into the sencha touch videos on vimeo. here is one that answers your question:

http://vimeo.com/20580117

Try the code given below it will help you understand the basic functionality of created a nested list using sencha touch.

Ext.setup({
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    icon: 'icon.png',
    glossOnIcon: false,
    onReady: function() {

    var data = {
        text: 'Groceries',
        items: [{
            text: 'Drinks',
            items: [{
                text: 'Water',
                items: [{
                    text: 'Sparkling',
                    leaf: true
                },{
                    text: 'Still',
                    leaf: true
            }]
            }, {
                text: 'Coffee',
                leaf: true
            }, {
                text: 'Espresso',
                leaf: true
            }, {
                text: 'Redbull',
                leaf: true
            }, {
                text: 'Coke',
                leaf: true
            }, {
                text: 'Diet Coke',
                leaf: true
           }]
        },{
        text: 'Fruit',
        items: [{
            text: 'Bananas',
            leaf: true
        },{
            text: 'Lemon',
            leaf: true
        }]
        },{
            text: 'Snacks',
            items: [{
                text: 'Nuts',
                leaf: true
        },{
            text: 'Pretzels',
            leaf: true
        },{
            text: 'Wasabi Peas',
            leaf: true
        }]
    },{
        text: 'Empty Category',
        items: []
    }]
};

    Ext.regModel('ListItem', {
        fields: [{name: 'text', type: 'string'}]
    });

    var store = new Ext.data.TreeStore({
        model: 'ListItem',
        root: data,
        proxy: {
            type: 'ajax',
            reader: {
                type: 'tree',
                root: 'items'
            }
        }
    });

    var leftNav = new Ext.NestedList({
        dock: 'left',
        useTitleAsBackText: true,
            title: '',
            displayField: 'text',
            width: '350',
            store: store    
    });

    new Ext.Panel({
        fullscreen: true,
        layout: {
            type: 'vbox',
            align: 'stretch'
        },
        defaults: {
            flex: 1
        },
        dockedItems:[leftNav]
    });
}

})

Following link will help you to find more info easily http://dev.sencha.com/deploy/touch/docs/.

Also look for examples in the sencha touch downloadable package.

Ignoring the PhoneGap stuff at the start, this tutorial has most of what you need.

That's really easy to do. Check out the Nested List in the Kitchen Sink under User Interface examples and click the "Source" button to see the code..

I went with a different approach, using raw HTML.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!