Answered: How to add different ICONS to List Items

I Need to add a different icons for each list items, I created a class name
.name {
@include box-flex(1);
font-weight: bold;
font-size: 1.4em;
overflow: hidden;
text-overflow: ellipsis;
display: block;
white-space: nowrap;
overflow: hidden;
padding: 0 0 0 40px;
background: url(../img/wlassistant.png) no-repeat center left;
}and used the class to be added to the list item
new Ext.List({
itemTpl: '<span class="name"><strong>{lblText}</strong></span>
This embeds the same icon for all the list Items. Can you please guide as to how I can display different icons for each list items.

Hi,
if your icons as to be dynamics, you have at least two ways to do that:

Add a new field (named for example iconUrl} to your list model which will contains your icon path, and then in your tpl you can include it in your tpl with an element like

Code:

'<img src="{iconUrl} />'

Add a new field (named for example iconCls) to your list model, and then in your css define the background image for every iconCls you are going to use. This is without doubt the better way to achieve that, because you can include inline images in your CSS limiting the server-side requests. In the same way, to include the iconCls in your tpl ,you can do it like follows:

Hi,
if your icons as to be dynamics, you have at least two ways to do that:

Add a new field (named for example iconUrl} to your list model which will contains your icon path, and then in your tpl you can include it in your tpl with an element like

Code:

'<img src="{iconUrl} />'

Add a new field (named for example iconCls) to your list model, and then in your css define the background image for every iconCls you are going to use. This is without doubt the better way to achieve that, because you can include inline images in your CSS limiting the server-side requests. In the same way, to include the iconCls in your tpl ,you can do it like follows:

Hi,
if your icons as to be dynamics, you have at least two ways to do that:

Add a new field (named for example iconUrl} to your list model which will contains your icon path, and then in your tpl you can include it in your tpl with an element like

Code:

'<img src="{iconUrl} />'

Add a new field (named for example iconCls) to your list model, and then in your css define the background image for every iconCls you are going to use. This is without doubt the better way to achieve that, because you can include inline images in your CSS limiting the server-side requests. In the same way, to include the iconCls in your tpl ,you can do it like follows: