自訂節點
參考樣本:自訂節點
建立代碼
<ul id="tree1" class="mini-tree" url="../data/tree.txt" style="width:200px;padding:5px;"
showTreeIcon="true" textField="text" idField="id"
ondrawnode="onDrawNode" showCheckBox="true">
</ul>
此時,我們監聽了“drawnode”事件。
drawnode 事件
function onDrawNode(e) {
var tree = e.sender;
var node = e.node;
var hasChildren = tree.hasChildren(node);
//所有子節點加上超連結
if (hasChildren == false) {
e.nodeHtml = '<a href="http://www.miniui.com/api/' + node.id + '.html" target="_blank">' + node.text + '</a>';
}
//父節點高亮顯示;子節點斜線、藍色、底線顯示
if (hasChildren == true) {
e.nodeStyle = 'font-weight:bold;';
} else {
e.nodeStyle = "font-style:italic;"; //nodeStyle
e.nodeCls = "blueColor"; //nodeCls
}
//修改預設的父子節點表徵圖
if (hasChildren == true) {
e.iconCls = "folder";
} else {
e.iconCls = "file";
}
//父節點的CheckBox全部隱藏
if (hasChildren == true) {
e.showCheckBox = false;
}
}