EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: amir-t on July 16, 2013, 02:34:34 AM



Title: TreeGrid iconCls- setting css dynamic style instead of css name
Post by: amir-t on July 16, 2013, 02:34:34 AM
Hi,
Is there any way to set a treeGrid node iconCls property by assigning the style itself like :
{background:url('icons/myIcon.gif') no-repeat;} ,
on the fly?
Instead of assigning the class name?

The problem is that i have a dynamic icons list, about 1000 icons, and i don't have them arranged in a full css external file which i can use its css classes names.
In addition, the url of the icons can be changed and therefore i need to set each node a dynamic image url of a certain icon instead of setting a specific css class name, which the iconCls property need to be filled with.

Regards.


Title: Re: TreeGrid iconCls- setting css dynamic style instead of css name
Post by: stworthy on July 16, 2013, 09:26:10 AM
A solution to solve this issue is to hide the original icon and use 'formatter' to add an icon to the left of tree field.
Code:
<style>
.tree-icon{
display:none;
}
</style>
Code:
$('#tg').treegrid({
columns:[[
{field:'name',title:'Name',width:150,
formatter:function(value){
return '<img src="..." style="width:16px;height:18px;vertical-align:bottom"/>'+value;
}
}
]]
});


Title: Re: TreeGrid iconCls- setting css dynamic style instead of css name
Post by: amir-t on July 17, 2013, 02:09:32 AM
It Works!! thanks a lot.