我希望在列表的详细视图中有一个转盘面板。我把带柔性3的转盘放在一个面板里。使用此代码,我确保面板项目中的tpl将工作。但我不知道如何解决旋转木马的问题。
tpl内部面板项目代码:
updateData:函数(newData,oldData){
this.down('component').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);
}
});
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);
}