<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
});
本文介绍如何使用ExtJS框架创建树形控件,并通过不同的图标样式来区分节点的开闭状态及叶节点。示例代码展示了如何定义树的根节点及多个子节点,并将这些节点组织成树形结构。
3333

被折叠的 条评论
为什么被折叠?



