如何制作sencha touch List显示界面


点击后的效果:



目录结构:



index.htm代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>List View</title>
    <link rel="stylesheet" href="sencha/1.0.1a/sencha-touch.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="stylesheets/styles.css" type="text/css" media="screen"/>

    <script src="sencha/1.0.1a/sencha-touch.js" type="text/javascript" charset="utf-8"></script>
    <script src="javascripts/index.js" type="text/javascript" charset="utf-8"></script>
    <script src="javascripts/data.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

</body>
</html>

index.js代码

ListDemo = new Ext.Application({
    name: "ListDemo",

    launch: function () {
        ListDemo.detailToolbar = new Ext.Toolbar({
            items: [{
                text: 'back',
                ui: 'back',
                handler: function () {
                    ListDemo.Viewport.setActiveItem('listwrapper', { type: 'slide', direction: 'right' });
                }
            }]
        });

        ListDemo.RightPanel= new Ext.Panel({
            id: 'rightPanel',
            tpl: 'Hello,world!'
            //dockedItems: [ListDemo.detailToolbar]
            
        });



        ListDemo.sss = new Ext.List({
            id: 'sss',
            store: ListDemo.ListStore,
            itemTpl: '<div class="contact">{firstName}{lastName}</div>',
            grouped: true
            //            onItemDisclosure: function (record) {
            //                var name = record.data.firstName + " " + record.data.lastName;
            //                ListDemo.detailToolbar.setTitle(name);
            //                ListDemo.detailPanel.update(record.data);
            //                ListDemo.Viewport.setActiveItem('detailpanel');
            //            }
        });


        ListDemo.detailPanel = new Ext.Panel({
            id: 'detailpanel',
            tpl: '<div class="contact">{firstName}{lastName}</div>',
            dockedItems: [ListDemo.detailToolbar],
            items: [ListDemo.sss]


        });


        ListDemo.ListPanel = new Ext.List({
            id: 'indexlist',
            store: ListDemo.ListStore,
            itemTpl: '<div class="contact">{firstName}{lastName}</div>',
            grouped: true,
            onItemDisclosure: function (record) {
                var name = record.data.firstName + " " + record.data.lastName;
                ListDemo.detailToolbar.setTitle(name);
                //ListDemo.detailPanel.update(record.data);
                ListDemo.Viewport.setActiveItem('detailpanel');
            }
        });


        
        ListDemo.listWrapper = new Ext.Panel({
            id: 'listwrapper',
            layout: 'hbox',
            items: [ListDemo.ListPanel,ListDemo.RightPanel],
            dockedItems:[{
                    xtype:'toolbar',
                    items: [
                        { ui: 'back', text: 'Back' },
                        { text: 'Default' },
                        { ui: 'round', text: 'Round' },


                        { xtype: 'spacer' },


                        {
                            xtype: 'segmentedbutton',
                            items: [
                                { text: 'Option 1' },
                                { text: 'Option 2', pressed: true },
                                { text: 'Option 3' }
                            ]
                        },


                        { xtype: 'spacer' },


                        { ui: 'action', text: 'Action' },
                        { ui: 'forward', text: 'Forward' },
                        {
                            xtype: 'segmentedbutton',
                            allowMultiple: true,
                            items: [
                                { text: 'Toggle 1', pressed: true },
                                { text: 'Toggle 2', pressed: true },
                                { text: 'Toggle 3' }
                            ]
                        }
                    ]
                                
                }]
        });



        
        
        ListDemo.Viewport = new Ext.Panel({
            fullscreen: true,
            layout: 'card',
            cardSwitchAnimation: 'slide',
            items: [ListDemo.listWrapper, ListDemo.detailPanel]
        });

    }
});


data.js代码

Ext.regModel('Contact', {
    fields: ['firstName', 'lastName']
});

ListDemo.ListStore = new Ext.data.Store({
    model: 'Contact',
    sorters:'lastName',
    getGroupString: function (record) {
        return record.get('lastName')[0];
    },
    data: [
        { firstName: "Domino", lastName: "Derval" },
        { firstName: "Elektra", lastName: "King" },
        { firstName: "Fiona", lastName: "Volpe" },
        { firstName: "Holly", lastName: "Goodhead" },
        { firstName: "Honey", lastName: "Rider" },
        { firstName: "Jill", lastName: "Masterton" },
        { firstName: "Kissy", lastName: "Suzuki" },
        { firstName: "Mary", lastName: "Goodnight" },
        { firstName: "Miranda", lastName: "Frost" },
        { firstName: "Molly", lastName: "Warmflash" },
        { firstName: "Paula", lastName: "Caplan" },
        { firstName: "Penelope", lastName: "Smallbone" },
        { firstName: "Plenty", lastName: "O'Toole" },
        { firstName: "Pussy", lastName: "Galore" },
        { firstName: "Strawberry", lastName: "Fields" },
        { firstName: "Sylvia", lastName: "Trench" },
        { firstName: "Tatiana", lastName: "Romanova" },
        { firstName: "Tilly", lastName: "Masterton" },
        { firstName: "Vesper", lastName: "Lynd" },
        { firstName: "Xenia", lastName: "Onatopp" }
    ]
});




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值