<style type="text/css">
/*不考虑节点的状态,同一用一种图标显示*/
.x-tree-node .your-iconCls{background-image: url(youricon.gif)}
/*为节点的开闭状态和叶节点状态分别设置样式*/
.x-tree-node-expanded .your-iconCls{background-image: url(youricon.gif)}
.x-tree-node-collapsed .your-iconCls{background-image: url(youricon2.gif)}
.x-tree-node-leaf .your-iconCls{background-image: url(youricon3.gif)}
</style>
代码:
var root=new Ext.tree.TreeNode({
id:"root",
text:"树的根"
});
var c1=new Ext.tree.TreeNode({
text:"子节点1",iconCls : 'treeiconCls'
})
var c2=new Ext.tree.TreeNode({
text:"子节点2",iconCls : 'treeiconCls'
});
var c3=new Ext.tree.TreeNode({
text:"子节点3",iconCls : 'treeiconCls'
});
var c4=new Ext.tree.TreeNode({
text:"子节点4"
});
root.appendChild(c1);
root.appendChild(c2);
c2.appendChild(c3);
c3.appendChild(c4);
var tree=new Ext.tree.TreePanel({
rootVisible:false,
root:root,
border:false,
autoWidth:true
});