我想加一个checkbox 该怎么加,最好把增加删除节点也说下
JS 代码如下:只是粘了一部分,因为我不知道该在哪里加,只是别人写的js// Node object节点对像
function Node(id, pid, name, url, title, target, icon, iconOpen, open) { this.id = id; this.pid = pid; this.name = name; this.url = url; this.title = title; this.target = target; this.icon = icon; this.iconOpen = iconOpen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p;};
// Tree object
function dTree(objName) {

this.config = {
checkbox: true,
target : null, folderLinks : false, useSelection : true, useCookies : true, useLines : false, useIcons : true, useStatusText : true, closeSameLevel : false, inOrder : false } this.icon = { root : 'tree/img/base.gif', folder : 'tree/img/folder.gif', folderOpen : 'tree/img/folderopen.gif', node : 'tree/img/page.gif', empty : 'tree/img/empty.gif', line : 'tree/img/line.gif', join : 'tree/img/join.gif', joinBottom : 'tree/img/joinbottom.gif', plus : 'tree/img/plus.gif', plusBottom : 'tree/img/plusbottom.gif', minus : 'tree/img/minus.gif', minusBottom : 'tree/img/minusbottom.gif', nlPlus : 'tree/img/nolines_plus.gif', nlMinus : 'tree/img/nolines_minus.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false;};// Adds a new node to the node arraydTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);};// Open/close all nodesdTree.prototype.openAll = function() { this.oAll(true);};dTree.prototype.closeAll = function() { this.oAll(false);};// Outputs the tree to the pagedTree.prototype.toString = function() { var str = '<div class="dtree">\n'; if (document.getElementById) { if (this.config.useCookies) this.selectedNode = this.getSelected(); str += this.addNode(this.root); } else str += 'Browser not supported.'; str += '</div>'; if (!this.selectedFound) this.selectedNode = null; this.completed = true; return str;};// Creates the tree structuredTree.prototype.addNode = function(pNode) {
var str = ''; var n=0; if (this.config.inOrder) n = pNode._ai; for (n; n<this.aNodes.length; n++) { if (this.aNodes[n].pid == pNode.id) { var cn = this.aNodes[n]; cn._p = pNode; cn._ai = n; this.setCS(cn); if (!cn.target && this.config.target) cn.target = this.config.target; if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); if (!this.config.folderLinks && cn._hc) cn.url = null; if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { cn._is = true; this.selectedNode = n; this.selectedFound = true; } str += this.node(cn, n); if (cn._ls) break; } } return str;
};前台代码<div class="dtree">
<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
<script type="text/javascript">
$(function(){
$.post("selectSysName.action",{},function(json){
for(var i=0;i<json.treeMap.len;i++){
alert(json.treeMap[i].sys_name);
}
},"json")

})
d = new dTree('d');
d.add(0,-1,'角色权限列表');
<c:forEach items="${li}" var="u" varStatus="v">
d.add(1,0,'Root');
d.add(${u.sys.sys_id},1,'${u.sys.sys_name}');
d.add(${u.page_id}+111,${u.sys.sys_id},'${u.page_name}');
</c:forEach>
document.write(d);
</script>
</div>