我需要将缩略图(小图片)附加到标记字段中的标签。
我发现了这个毫无疑问的问题: https://www.sencha.com/forum/showthread.php?330338-Ext-form-field-Tag-HTML-encodes-the-labelTpl
我发现并编辑了一些代码,以便在组合框上显示图像: https://fiddle.sencha.com/#fiddle/1jdp
但没有成功使其在我的建筑师最终代码中发挥作用。
感谢
代码(不在此处运行,运行上面的fiddle):
Ext.application({
name: 'SnirFiddle',// by snir elgabsi
launch: function() {
var cities = Ext.create('Ext.data.Store', {
fields: ['name', 'isTitle'],
data: [
{ type: 'Animal', petname: 'Human', img:'http://i56.photobucket.com/albums/g181/thejoker1x/th_HomerFalling.gif' },
{ type: 'Animal', petname: 'Lion', img:'http://icons.veryicon.com/ico/Animal/Animal/lion.ico'},
{ type: 'Bird', petname: 'Starling', img:'http://ted-parker.com/wp-content/uploads/2015/11/StarlingTHUMB.jpg' },
{ type: 'Bird', petname: 'Dove', img:'https://cdn2.iconfinder.com/data/icons/outline-signs/350/dove-512.png' },
{ type: 'Fish', petname: 'Nemo', img:'https://cdn2.iconfinder.com/data/icons/aquatic-wildlife/135/_nemo-128.png' }
]
});
Ext.create('Ext.form.field.Tag', {
fieldLabel: 'Choose Pet',
store: cities,
renderTo: Ext.getBody(),
tpl: Ext.create('Ext.XTemplate',
'{[this.currentKey = null]}',
'<tpl for=".">',
'<tpl if="this.shouldShowHeader(type)">',
'<div class="group-header"><b>{[this.currentKey = values.type]}</b></div>',
'</tpl>',
'<img src="{img}" style="float: left; width: 32px;">',
'<div class="x-boundlist-item">{petname}</div>',
'</tpl>',
{
shouldShowHeader: function(key){
return this.currentKey != key;
},
getHeader: function(key){
this.currentKey = key;
return key;
}
})
});
}
});