[英]How do I add an image to a combo in Extjs?
I managed to add a images in the extjs combo selection list however after selecting an item did not manage to have the same images displayed int he collapsed combo. 我设法在extjs组合选择列表中添加了一个图像,但是在选择一个项目后,在折叠组合中并没有显示相同的图像。 I tried changing the template (displayTpl) by adding some custom HTML however it will get escaped. 我尝试通过添加一些自定义HTML来更改模板(displayTpl),但是它将被转义。 any help would be appreciated. 任何帮助,将不胜感激。
Thanks 谢谢
this.chartCombo = Ext.create('Ext.form.field.ComboBox', {
height: '20',
fieldLabel: 'Chart Type',
displayField: 'chartLabel',
valueField: 'chartValue',
store: chartComboDataSource,
queryMode: 'local',
listConfig: {
getInnerTpl: function() {
this.cls = 'option-list-chart-img';
return "<img class='{cssClassName}'/> {chartLabel}";
}
}
});
It doesn't work because the collapsed combo is just a simple <input>
element that can't contain HTML. 这是行不通的,因为折叠的组合只是一个简单的<input>
元素,不能包含HTML。 I suggest you set the image as a background image to the <input>
, switching it programmatically when selection changes. 我建议您将图像设置为<input>
的背景图像,并在选择更改时以编程方式对其进行切换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.