EasyUI Forum
November 02, 2025, 08:17:37 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: TreeGrid iconCls- setting css dynamic style instead of css name  (Read 16305 times)
amir-t
Newbie
*
Posts: 48


View Profile
« 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.
« Last Edit: July 16, 2013, 03:59:58 AM by amir-t » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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;
}
}
]]
});
Logged
amir-t
Newbie
*
Posts: 48


View Profile
« Reply #2 on: July 17, 2013, 02:09:32 AM »

It Works!! thanks a lot.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!