2014-06-27 144 views
2

我想将图标添加到我的工具栏(任意 - 不与按钮关联)。将图标添加到Extjs工具栏

在我的CSS我定义URL是这样的:

.myCoolLookingIcon { 
    background-image: url('../ext-theme-gray/images/grid/columns.gif'); 
} 

而且,如果我用iconCls设置按钮图标正常工作。

我想在一个标签或图像

该图标我曾尝试:

  xtype: 'label', 
      iconCls: 'myCoolLookingIcon ' 

  xtype: 'image', 
      html: '<img class="myCoolLookingIcon "/>' 

但是这似乎并没有在这两种情况下工作。

+0

你不能只是配置配置。标签没有'iconCls'配置。 –

回答

5

这是实现你想要什么(不使用iconCls)的方法之一

xtype:'label', 
html: '<img src=\"path_to_icon\">' 

试试这个:

xtype:'label', 
html: '<img class="className" width="20" height="20">' 

给予的宽度和高度,使得它的工作。

+0

是的,我看着那个。对我来说似乎有点太凌乱 –

+0

添加了一些东西。不能正常工作 –

+0

ahh在我的例子中忘了宽度和高度:)谢谢 –

1

最终我最终这样做了。有点哈克,但它的工作。

{ 
    xtype: 'label', 
    itemId: 'labelWithIcon', 
    text: '', 
    cls: 'classNameWithImgBackground', 
    listeners: { 
     render: function() { 
     this.setText('<span style="margin-left: 16px;">Label Text</span>', false); 
     } 
    } 
}