最近在做个项目的时候,发现Coolit Treepanel ico的在后台设置treeNode.Icon = Icon.Accept竟然不起作用,于是乎度娘、谷歌问了几遍,终于有点发现,通过改Cls可以自定义图标,但是他给的那个方法不起作用,最后打开页面的源文件,发现其实每个图标经过编译后的css是这样的:
<style type="text/css">
.icon-house{background-image:url(/hfproject/icons/house-png/coolite.axd) !important;}
.icon-cancel{background-image:url(/hfproject/icons/cancel-png/coolite.axd) !important;}
.icon-find{background-image:url(/hfproject/icons/find-png/coolite.axd) !important;}
.icon-housestar{background-image:url(/hfproject/icons/house_star-png/coolite.axd) !important;}
</style>
可以发现,ico的样式就是:图标名称-png
依葫芦画瓢,OK了!
这个是我自定义的css:
.icon-user{background-image:url(/hfproject/icons/folder_user-png/coolite.axd) !important;}
这个是我的后台代码:
for (int s = 0; s < sp.Length; s++)
{
Coolite.Ext.Web.TreeNode sptreeNode = new Coolite.Ext.Web.TreeNode();
sptreeNode.Leaf = true;
sptreeNode.IconCls = "icon-user";
sptreeNode.Text = Suppliers.FindSuppliersBySupplierID(sp[s]).Name;
sptreeNode.NodeID = sp[s];
treeNode.Nodes.Add(sptreeNode);
}
效果: