check item icon in sencha

跟風遠走 提交于 2019-12-11 07:37:20

问题


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

but i couldn't ! even though i use iconCls property. anyone have done this before ?


回答1:


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



来源:https://stackoverflow.com/questions/11213392/check-item-icon-in-sencha

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!