日期:2014-05-16  浏览次数:20406 次

js 做的 checkbox tree
dtree.css文件内容:
.dtree {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #666;
white-space: nowrap;
}
.dtree img {
border: 0px;
vertical-align: middle;
}
.dtree a {
color: #333;
text-decoration: none;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
}
.dtree a.nodeSel {
background-color: #c0d2ec;
}
.dtree .clip {
overflow: hidden;
}


tree.js内容
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr?              |
|                                                   |
| This script can be used freely as long as all     |
| copyright messages are intact.                    |
|                                                   |
| Updated: 17.04.2003                               |
|--------------------------------------------------*/


//==================================================
//luzhilin
//==================================================
//修改历史:
//1、2006-05-11 将dtree修改成可以选择的权限树,
//   将name转变成<input type='checkbox'>
//
//==================================================
// Node object
function Node(id, pid, cname, cvalue, cshow, cchecked, cdisabled, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
//chechbox的名称
this.cname = cname;
//chechbox的值
this.cvalue = cvalue;
//chechbox的显示
this.cshow = cshow;
//chechbox是否被选中,默认是不选
this.cchecked = cchecked||false;
//chechbox是否可用,默认是可用
this.cdisabled = cdisabled||false;
//节点链接,默认是虚链接
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 = {
target : null,
folderLinks : false,
useSelection : false,
useCookies : false,
useLines : true,
useIcons : false,
useStatusText : true,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : 'img/base.gif',
folder : 'img/folder.gif',
folderOpen : 'img/folderopen.gif',
node : 'img/page.gif',
empty : 'img/empty.gif',
line : 'img/line.gif',
join : 'img/join.gif',
joinBottom : 'img/joinbottom.gif',
plus : 'img/plus.gif',
plusBottom : 'img/plusbottom.gif',
minus : 'img/minus.gif',
minusBottom : 'img/minusbottom.gi