ztree的css文件metroStyle_adm.css中添加:
.ztree li span.button.dept_ico_open{margin-right:2px; background: url(./img/group.png) 0 0 no-repeat; vertical-align:top; *vertical-align:middle}
.ztree li span.button.dept_ico_close{margin-right:2px; background: url(./img/group.png) 0 0 no-repeat; vertical-align:top; *vertical-align:middle}
.ztree li span.button.dept_ico_docu{margin-right:2px; background: url(./img/group.png) 0 0 no-repeat; vertical-align:top; *vertical-align:middle}
在返回的树节点json数据中:
var zNodes =[
{ id:1, pId:0, name:"展开、折叠 自定义图标不同", open:true, iconSkin:"hostgroup"},
{ id:11, pId:1, name:"叶子节点1", iconSkin:"dept"},
{ id:12, pId:1, name:"叶子节点2", iconSkin:"dept"},
{ id:13, pId:1, name:"叶子节点3", iconSkin:"dept"},
{ id:2, pId:0, name:"展开、折叠 自定义图标相同", open:true, iconSkin:"hostgroup"},
{ id:21, pId:2, name:"叶子节点1", iconSkin:"dept"},
{ id:22, pId:2, name:"叶子节点2", iconSkin:"dept"},
{ id:23, pId:2, name:"叶子节点3", iconSkin:"dept"},
{ id:3, pId:0, name:"不使用自定义图标", open:true },
{ id:31, pId:3, name:"叶子节点1"},
{ id:32, pId:3, name:"叶子节点2"},
{ id:33, pId:3, name:"叶子节点3"}
];
iconSkin属性值设定为上面css中的“dept”即可。