tpl内部组合项目

时间:2013-06-24 11:50:31

标签: sencha-touch getattribute

我想在列表的详细视图中使用轮播面板。我把带有flex 3的旋转木马放在面板内。使用此代码,我确保面板项内的tpl将起作用。但我不知道如何解决旋转木马的问题。

面板项目内的tpl代码:

  

updateData:function(newData,oldData){
  this.down( '组件')使用setData(newData);
  this.getAt(0).setData(newData); this.getAt(1).setData(newData);
  }

我的WorkDetail.js的完整代码

Ext.define('Portfolio.view.WorkDetail', {
    extend: 'Ext.Panel',
    xtype: 'workdetail',

    requires: [
        'Ext.carousel.Carousel'
    ],

    config: {
        xtype: 'panel',
        layout: 'hbox',
        align: 'stretch',
        styleHtmlContent: true,
        scrollable: null,

        items: [
            {
                flex:3,
                xtype: 'carousel',
                // HERE THE TLP WORKS
                // tpl: '<img src="{bigImage1}"></img>',
                // style: 'background-color: #456370;',

                items: [
                    {
                        // TPL DON'T WORK
                        tpl: '<img src="{bigImage1}"></img>',
                        style: 'background-color: #E84F17;'
                    },
                    {
                        // TPL DON'T WORK
                        tpl: '<img src="{bigImage2}"></img>',
                        style: 'background-color: #4DBAB6;'
                    },
                    {
                        // TPL DON'T WORK
                        tpl: '<img src="{bigImage3}"></img>',
                        style: 'background-color: #BBB399;',
                    }
                ]
            },
            {
                // HERE THE TLP WORKS
                flex:1,
                tpl: '<p>{workDiscriptionLarge}</p> <p>{workDate}</P> <a href="{hyperLink}">Bekijk de website</a>'
            }
        ]
    },

    updateData: function(newData, oldData) {
  this.down('component').setData(newData);
  this.getAt(0).setData(newData); 
  this.getAt(1).setData(newData); 
    }

});

1 个答案:

答案 0 :(得分:0)

this.down('component').setData(newData);
this.getAt(0).setData(newData);

这两行将定位您的Carousel项目,因此不会填充子项目的模板。

this.getAt(1).setData(newData);

此行将定位您看到模板正常工作的第二个项目。

您需要单独定位每个Carousel项目,并调用每个项目的setData方法以填充模板。

// untested :)
var components = this.getAt(0).query('component');

for(var i = 0; i < components.length; i++){
    components[i].setData(newData);
}