在煎茶中检查项目图标 [英] check item icon in sencha
问题描述
我是Extjs和Sencha的新手.我开始设计UI,并且可以成功添加带按钮的iconCls.现在我需要将图标添加到Checkitem菜单
I am new at Extjs and Sencha. i started to design my UI and i could successfully add an iconCls with buttons. now i need to add icon to a checkitem menue http://dev.sencha.com/deploy/ext-4.1.0-gpl/docs/index.html#!/api/Ext.menu.CheckItem
但是我做不到!即使我使用iconCls属性.有人做过吗?
but i couldn't ! even though i use iconCls property. anyone have done this before ?
推荐答案
如果只希望图标位于文本旁边,则只需在呈现菜单项之后插入图像即可.
If you just want the icon right next to the text, you can just insert an image after the menu item is rendered
Ext.create('Ext.menu.Menu', {
width: 100,
height: 200,
floating: false,
renderTo: Ext.getBody(),
items: [{
xtype: 'menucheckitem',
text: 'select all',
listeners: {
render: function(comp) {
Ext.DomHelper.insertAfter(comp.getEl().down(".x-menu-item-icon"), {
tag: 'img',
src: "http://flyosity.com/images/_blogentries/networkicon/stepfinal2.png",
width: 16,
height: 16
});
}
}
}]
});
理想情况下,您将创建一个插件或子类,以便可以重用此功能.上面的代码没有重新对齐分隔符,它是整个菜单的单个分隔符,但它应该为您提供一个良好的开端
Ideally, you'd create a plugin or a subclass so you can reuse this functionality. The above code does not realign the separator, it's single separator for the entire menu, but it should give you a head start
这篇关于在煎茶中检查项目图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!