Sencha Touch,在同一面板上有文字(空白)区域的旋转木马?

时间:2011-01-09 04:51:50

标签: extjs sencha-touch

全新的Sencha,我正在尝试使用卡片,其中底部是旋转木马,并且在其上面是一个开放区域,根据在下面的旋转木马中点击的图像,将更新文本。知道我怎么能这样做吗?谢谢!

1 个答案:

答案 0 :(得分:2)

我认为这可以胜任:

new Ext.Application({
    launch: function() {

        // DATA

        Ext.regModel('MenuItem', {
            fields: ['id', 'name']
        });
        var menuItems = new Ext.data.Store({
            model: 'MenuItem',
            data: [
                {id:1, name:'Page 1'},
                {id:2, name:'Page 2'},
                {id:3, name:'Page 3'},
                {id:4, name:'Page 4'},
                {id:5, name:'Page 5'}
            ]
        });


        Ext.regModel('PictureItem', {
            fields: ['id', 'url']
        });
        var pictureItems = new Ext.data.Store({
            model: 'PictureItem',
            data: [
                {id:1, url:'http://farm4.static.flickr.com/3154/2370778225_f448a2d5a4.jpg'},
                {id:2, url:'http://farm1.static.flickr.com/3560/3363355104_b0175610d9.jpg'},
                {id:3, url:'http://farm4.static.flickr.com/3092/2869861643_cdc051b5b3.jpg'},
                {id:4, url:'http://farm4.static.flickr.com/3448/3252866261_7eb3d01114.jpg'},
                {id:5, url:'http://farm3.static.flickr.com/2303/2508275237_5ecf4b3532.jpg'},
                {id:6, url:'http://farm4.static.flickr.com/3154/2370778225_f448a2d5a4.jpg'},
                {id:7, url:'http://farm1.static.flickr.com/3560/3363355104_b0175610d9.jpg'},
                {id:8, url:'http://farm4.static.flickr.com/3092/2869861643_cdc051b5b3.jpg'},
                {id:9, url:'http://farm4.static.flickr.com/3448/3252866261_7eb3d01114.jpg'},
            ]
        });


        // UI

        var topBar = new Ext.Toolbar({
            dock: 'top',
            title: 'Ryan\'s layout',
            items: [
                {text: 'Button 1'},
                {text: 'Button 2'}
            ]
        });

        var leftList = new Ext.List({
            dock: 'left',
            width: 135,
            itemTpl: '{name}',
            singleSelect: true,
            store: menuItems,
            listeners:{
                selectionchange: function (model, records) {
                    if (records[0]) {
                        viewport.update(records[0]);
                    }
                }
            }

        });

        var pictureBar = new Ext.Toolbar({
            dock: 'bottom',
            layout: 'hbox',
            scroll: 'horizontal',
            height: 100,
            defaults: {
                cls: 'pic',
                height: 80,
                width: 120,
            },
        });

        var viewport = new Ext.Panel({
            fullscreen: true,
            dockedItems: [topBar, pictureBar, leftList],
            tpl:'<tpl for=".">{store.model.modelName} {data.id}</tpl>'
        });


        // BIND IMAGE STORE TO TOOLBAR

        pictureItems.each(function (pictureItem) {
            pictureBar.add(new Ext.Button({
                style:{background: 'url(http://i.tinysrc.mobi/120/80/' + pictureItem.data.url + ')'},
                listeners:{
                    tap: function () {
                        viewport.update(pictureItem);
                    }
                }
            }));
        });
        pictureBar.doLayout();

    }
});

并生成类似于:http://cl.ly/3vLZ

的用户界面