這是在網站下載的一個以Javascript+xml的樹型列表
這個列表界面非常的漂亮
但是由於裡面內容比較復雜
而現在項目需要用到這個列表
我到現在還沒有摸清怎麼在裡面讓點擊一個樹型的項目轉到別的網頁裡面去
希望有興趣的朋友一起研究一下
部分代碼如下
<script>
function dtmlXMLLoaderObject(funcObject
dhtmlObject){
this
xmlDoc=
;
this
onloadAction=funcObject||null;
this
mainObject=dhtmlObject||null;
return this;
};
dtmlXMLLoaderObject
prototype
waitLoadFunction=function(dhtmlObject){
this
check=function(){
if(!dhtmlObject
xmlDoc
readyState)dhtmlObject
onloadAction(dhtmlObject
mainObject);
else{
if(dhtmlObject
xmlDoc
readyState !=
)return false;
else dhtmlObject
onloadAction(dhtmlObject
mainObject);}
};
return this
check;
};
dtmlXMLLoaderObject
prototype
getXMLTopNode=function(tagName){
if(this
xmlDoc
responseXML){var temp=this
xmlDoc
responseXML
getElementsByTagName(tagName);
var z=temp[
];}
else var z=this
xmlDoc
documentElement;
if(z)return z;
alert(
Incorrect XML
);
return document
createElement(
DIV
);
};
dtmlXMLLoaderObject
prototype
loadXMLString=function(xmlString){
try
{
var parser = new DOMParser();
this
xmlDoc = parser
parseFromString(xmlString
text/xml
);
}
catch(e){
this
xmlDoc = new ActiveXObject(
Microsoft
XMLDOM
);
this
xmlDoc
loadXML(xmlString);
}
this
onloadAction(this
mainObject);
}
dtmlXMLLoaderObject
prototype
loadXML=function(filePath){
try
{
this
xmlDoc = new XMLHttpRequest();
this
xmlDoc
open(
GET
filePath
true);
this
xmlDoc
onreadystatechange=new this
waitLoadFunction(this);
this
xmlDoc
send(null);
}
catch(e){
if(document
implementation && document
implementation
createDocument)
{
this
xmlDoc = document
implementation
createDocument(
null);
this
xmlDoc
onload = new this
waitLoadFunction(this);
}
else
{
this
xmlDoc = new ActiveXObject(
Microsoft
XMLDOM
);
this
xmlDoc
async=
true
;
this
xmlDoc
onreadystatechange=new this
waitLoadFunction(this);
}
this
xmlDoc
load(filePath);
}
};
function callerFunction(funcObject
dhtmlObject){
this
handler=function(e){
if(!e)e=event;
funcObject(e
dhtmlObject);
return true;
};
return this
handler;
};
function getAbsoluteLeft(htmlObject){
var xPos = htmlObject
offsetLeft;
var temp = htmlObject
offsetParent;
while(temp != null){
xPos+= temp
offsetLeft;
temp = temp
offsetParent;
}
return xPos;
}
function getAbsoluteTop(htmlObject){
var yPos = htmlObject
offsetTop;
var temp = htmlObject
offsetParent;
while(temp != null){
yPos+= temp
offsetTop;
temp = temp
offsetParent;
}
return yPos;
}
function convertStringToBoolean(inputString){if(typeof(inputString)==
string
)inputString=
inputString
toLowerCase();
switch(inputString){
case
:
case
true
:
case
yes
:
case
y
:
case
:
case true:
return true;
break;
default: return false;
}
}
function getUrlSymbol(str){
if(str
indexOf(
?
)!=
)
return
&
else
return
?
}
function dhtmlDragAndDropObject(){
this
lastLanding=
;
this
dragNode=
;
this
dragStartNode=
;
this
dragStartObject=
;
this
tempDOMU=null;
this
tempDOMM=null;
this
waitDrag=
;
if(window
dhtmlDragAndDrop)return window
dhtmlDragAndDrop;
window
dhtmlDragAndDrop=this;
return this;
};
dhtmlDragAndDropObject
prototype
removeDraggableItem=function(htmlNode){
htmlNode
onmousedown=null;
htmlNode
dragStarter=null;
htmlNode
dragLanding=null;
}
dhtmlDragAndDropObject
prototype
addDraggableItem=function(htmlNode
dhtmlObject){
htmlNode
onmousedown=this
preCreateDragCopy;
htmlNode
dragStarter=dhtmlObject;
this
addDragLanding(htmlNode
dhtmlObject);
}
dhtmlDragAndDropObject
prototype
addDragLanding=function(htmlNode
dhtmlObject){
htmlNode
dragLanding=dhtmlObject;
}
dhtmlDragAndDropObject
prototype
preCreateDragCopy=function(e)
{
if(window
dhtmlDragAndDrop
waitDrag){
window
dhtmlDragAndDrop
waitDrag=
;
document
body
onmouseup=window
dhtmlDragAndDrop
tempDOMU;
document
body
onmousemove=window
dhtmlDragAndDrop
tempDOMM;
return;
}
window
dhtmlDragAndDrop
waitDrag=
;
window
dhtmlDragAndDrop
tempDOMU=document
body
onmouseup;
window
dhtmlDragAndDrop
tempDOMM=document
body
onmousemove;
window
dhtmlDragAndDrop
dragStartNode=this;
window
dhtmlDragAndDrop
dragStartObject=this
dragStarter;
document
body
onmouseup=window
dhtmlDragAndDrop
preCreateDragCopy;
document
body
onmousemove=window
dhtmlDragAndDrop
callDrag;
};
dhtmlDragAndDropObject
prototype
callDrag=function(e){
if(!e)e=window
event;
dragger=window
dhtmlDragAndDrop;
if(!dragger
dragNode){
dragger
dragNode=dragger
dragStartObject
_createDragNode(dragger
dragStartNode);
document
body
appendChild(dragger
dragNode);
document
body
onmouseup=dragger
stopDrag;
dragger
waitDrag=
;
}
dragger
dragNode
style
left=e
clientX+
+document
body
scrollLeft;dragger
dragNode
style
top=
e
clientY+
+document
body
scrollTop;
if(!e
srcElement)var z=e
target;else z=e
srcElement;
dragger
checkLanding(z);
}
dhtmlDragAndDropObject
prototype
checkLanding=function(htmlObject){
if(htmlObject
dragLanding){if(this
lastLanding)this
lastLanding
dragLanding
_dragOut(this
lastLanding);
this
lastLanding=htmlObject;this
lastLanding=this
lastLanding
dragLanding
_dragIn(this
lastLanding
this
dragStartNode);}
else{
if(htmlObject
tagName!=
BODY
)this
checkLanding(htmlObject
parentNode);
else{if(this
lastLanding)this
lastLanding
dragLanding
_dragOut(this
lastLanding);this
lastLanding=
;}
}
}
dhtmlDragAndDropObject
prototype
stopDrag=function(e){
dragger=window
dhtmlDragAndDrop;
if(dragger
lastLanding)dragger
lastLanding
dragLanding
_drag(dragger
dragStartNode
dragger
dragStartObject
dragger
lastLanding);
dragger
lastLanding=
;
dragger
dragNode
parentNode
removeChild(dragger
dragNode);
dragger
dragNode=
;
dragger
dragStartNode=
;
dragger
dragStartObject=
;
document
body
onmouseup=dragger
tempDOMU;
document
body
onmousemove=dragger
tempDOMM;
dragger
tempDOMU=null;
dragger
tempDOMM=null;
dragger
waitDrag=
;
}
</script>
<!
dhtmlXTree
js
>
<script>
function dhtmlXTreeObject(htmlObject
width
height
rootId){
if(typeof(htmlObject)!=
object
)
this
parentObject=document
getElementById(htmlObject);
else
this
parentObject=htmlObject;
this
mytype=
tree
;
this
width=width;
this
height=height;
this
rootId=rootId;
this
style_pointer=
pointer
;
if(navigator
appName ==
Microsoft Internet Explorer
)this
style_pointer=
hand
;
this
hfMode=
;
this
nodeCut=
;
this
XMLsource=
;
this
XMLloadingWarning=
;
this
_globalIdStorage=new Array();
this
globalNodeStorage=new Array();
this
_globalIdStorageSize=
;
this
treeLinesOn=true;
this
checkFuncHandler=
;
this
openFuncHandler=
;
this
dblclickFuncHandler=
;
this
tscheck=false;
this
timgen=true;
this
imPath=
treeGfx/
;
this
checkArray=new Array(
iconUnCheckAll
gif
iconCheckAll
gif
iconCheckGray
gif
);
this
lineArray=new Array(
line
gif
line
gif
line
gif
blank
gif
blank
gif
);
this
minusArray=new Array(
minus
gif
minus
gif
minus
gif
minus
gif
minus
gif
);
this
plusArray=new Array(
plus
gif
plus
gif
plus
gif
plus
gif
plus
gif
);
this
imageArray=new Array(
leaf
gif
folderOpen
gif
folderClosed
gif
);
this
cutImg= new Array(
);
this
cutImage=
but_cut
gif
;
this
dragger= new dhtmlDragAndDropObject();
lNode=new dhtmlXTreeItemObject(this
rootId
this);
lNode
childNodes[
]
childNodes[
]
style
display=
none
;
lNode
childNodes[
]
childNodes[
]
childNodes[
]
className=
hiddenRow
;
this
allTree=this
_createSelf();
this
allTree
appendChild(lNode);
this
allTree
onselectstart=new Function(
return false;
);
this
XMLLoader=new dtmlXMLLoaderObject(this
_parseXMLTree
this);
this
dragger
addDragLanding(this
allTree
this);
return this;
};
function dhtmlXTreeItemObject(itemId
itemText
parentObject
treeObject
actionHandler
mode){
lNode=
;
this
acolor=
;
this
scolor=
;
this
tr=
;
this
childsCount=
;
this
tempDOMM=
;
this
tempDOMU=
;
this
dragSpan=
;
this
dragMove=
;
this
span=
;
this
closeble=
;
this
childNodes=new Array();
this
checkstate=
;
this
treeNod=treeObject;
this
label=itemText;
this
parentObject=parentObject;
this
actionHandler=actionHandler;
this
images=new Array(treeObject
imageArray[
]
treeObject
imageArray[
]
treeObject
imageArray[
]);
this
id=treeObject
_globalIdStorageAdd(itemId
this);
if(this
treeNod
checkBoxOff)lNode=this
treeNod
_createItem(
this
mode);
else lNode=this
treeNod
_createItem(
this
mode);
lNode
objBelong=this;
return this;
};
dhtmlXTreeObject
prototype
_globalIdStorageAdd=function(itemId
itemObject){
if(this
_globalIdStorageFind(itemId)){d=new Date();itemId=d
valueOf()+
_
+itemId;return this
_globalI
dStorageAdd(itemId
itemObject);}
this
_globalIdStorage[this
_globalIdStorageSize]=itemId;
this
globalNodeStorage[this
_globalIdStorageSize]=itemObject;
this
_globalIdStorageSize++;
return itemId;
};
dhtmlXTreeObject
prototype
_globalIdStorageSub=function(itemId){
for(var i=
;i<this
_globalIdStorageSize;i++)
if(this
_globalIdStorage[i]==itemId)
{
this
_globalIdStorage[i]=this
_globalIdStorage[this
_globalIdStorageSize
];
this
globalNodeStorage[i]=this
globalNodeStorage[this
_globalIdStorageSize
];
this
_globalIdStorageSize
;
this
_globalIdStorage[this
_globalIdStorageSize]=
;
this
globalNodeStorage[this
_globalIdStorageSize]=
;
}
};
dhtmlXTreeObject
prototype
_globalIdStorageFind=function(itemId){
for(var i=
;i<this
_globalIdStorageSize;i++)
if(this
_globalIdStorage[i]==itemId)
return this
globalNodeStorage[i];
return
;
};
dhtmlXTreeObject
prototype
_drawNewTr=function(htmlObject)
{
var tr =document
createElement(
tr
);
var td
=document
createElement(
td
);
var td
=document
createElement(
td
);
td
appendChild(document
createTextNode(
));
lSpan=
;td
appendChild(htmlObject);tr
appendChild(td
);tr
appendChild(td
);
return tr;
};
dhtmlXTreeObject
prototype
loadXMLString=function(xmlString){this
XMLLoader
loadXMLString(xmlString);};
dhtmlXTreeObject
prototype
loadXML=function(file){this
XMLLoader
loadXML(file);};
dhtmlXTreeObject
prototype
_attachChildNode=function(parentObject
itemId
itemText
itemActionHandler
image
image
image
optionStr
childs
url
beforeNode){
if(beforeNode)parentObject=beforeNode
parentObject;
if(((parentObject
XMLload==
)&&(this
XMLsource))&&(!this
XMLloadingWarning))
{
parentObject
XMLload=
;this
loadXML(this
XMLsource+getUrlSymbol(this
XMLsource)+
itemId=
+escape(emId));
}
var Count=parentObject
childsCount;
var Nodes=parentObject
childNodes;
if((!itemActionHandler)&&(this
aFunc))itemActionHandler=this
aFunc;
Nodes[Count]=new dhtmlXTreeItemObject(itemId
itemText
parentObject
this
itemActionHandler
);
if(image
)Nodes[Count]
images[
]=image
;
if(image
)Nodes[Count]
images[
]=image
;
if(image
)Nodes[Count]
images[
]=image
;
parentObject
childsCount++;
var tr=this
_drawNewTr(Nodes[lNode);
if(this
XMLloadingWarning)
Nodes[lNode
parentNode
parentNode
style
display=
none
;
if(optionStr){
var tempStr=optionStr
split(
);
for(var i=
;i<tempStr
length;i++)
{
switch(tempStr[i])
{
case
TOP
: if(parentObject
childsCount>
)beforeNode=lNode
childNodes[
]
childNodes[
]
nodem
previousSibling;break;
}
};
};
if((beforeNode)&&(beforeNode
tr
nextSibling))
lNode
childNodes[
]
insertBefore(tr
beforeNode
tr
nextSibling);
else
lNode
childNodes[
]
appendChild(tr);
if(this
XMLsource)if((childs)&&(childs!=
))Nodes[Count]
XMLload=
;else Nodes[Count]
XMLload=
;
Nodes[Count]
tr=tr;
tr
nodem=Nodes[Count];
if(emId==
)
tr
childNodes[
]
className=
hitemIddenRow
;
if(optionStr){
var tempStr=optionStr
split(
);
for(var i=
;i<tempStr
length;i++)
{
switch(tempStr[i])
{
case
SELECT
: this
selectItem(itemId
false);break;
case
CALL
: this
selectItem(itemId
true);break;
case
CHILD
: Nodes[Count]
XMLload=
;break;
case
CHECKED
:
if(this
XMLloadingWarning)
this
setCheckList+=itemId;
else
this
setCheck(itemId
);
break;
case
OPEN
: Nodes[Count]
openMe=
;break;
}
};
};
if(!this
XMLloadingWarning)
{
if(this
_getOpenState(parentObject)<
)
this
openItem(parentObject
id);
if(beforeNode)
{
this
_correctPlus(beforeNode);
this
_correctLine(beforeNode);
}
this
_correctPlus(parentObject);
this
_correctLine(parentObject);
this
_correctPlus(Nodes[Count]);
if(parentObject
childsCount>=
)
{
this
_correctPlus(Nodes[parentObject
childsCount
]);
this
_correctLine(Nodes[parentObject
childsCount
]);
}
if(parentObject
childsCount!=
)this
_correctPlus(Nodes[
]);
if(this
tscheck)this
_correctCheckStates(parentObject);
}
return Nodes[Count];
};
dhtmlXTreeObject
prototype
insertNewItem=function(parentId
itemId
itemText
itemActionHandler
image
image
image
optionStr
childs
url){
var parentObject=this
_globalIdStorageFind(parentId);
if(!parentObject)return(
);
return this
_attachChildNode(parentObject
itemId
itemText
itemActionHandler
image
image
image
optionStr
childs
url);
};
dhtmlXTreeObject
prototype
_parseXMLTree=function(dhtmlObject
node
parentId
level){
dhtmlObject
XMLloadingWarning=
;
var nodeAskingCall=
;
if(!node){
node=dhtmlObject
XMLLoader
getXMLTopNode(
tree
);
parentId=node
getAttribute(
id
);
dhtmlObject
setCheckList=
;
}
for(var i=
;i<node
childNodes
length;i++)
{
if((node
childNodes[i]
nodeType==
)&&(node
childNodes[i]
tagName ==
item
))
{
var name=node
childNodes[i]
getAttribute(
text
);
var cId=node
childNodes[i]
getAttribute(
id
);
var im
=node
childNodes[i]
getAttribute(
im
);
var im
=node
childNodes[i]
getAttribute(
im
);
var im
=node
childNodes[i]
getAttribute(
im
);
var aColor=node
childNodes[i]
getAttribute(
aCol
);
var sColor=node
childNodes[i]
getAttribute(
sCol
);
var chd=node
childNodes[i]
getAttribute(
child
);
var atop=node
childNodes[i]
getAttribute(
top
);
var aopen=node
childNodes[i]
getAttribute(
open
);
var aselect=node
childNodes[i]
getAttribute(
select
);
var acall=node
childNodes[i]
getAttribute(
call
);
var achecked=node
childNodes[i]
getAttribute(
checked
);
var closeable=node
childNodes[i]
getAttribute(
closeable
);
var url=node
childNodes[i]
getAttribute(
url
);
var zST=
;
if(aselect)zST+=
SELECT
;
if(atop)zST+=
TOP
;
if(acall)nodeAskingCall=cId;
if(achecked)zST+=
CHECKED
;
if((aopen)&&(aopen!=
))zST+=
OPEN
;
var temp=dhtmlObject
_globalIdStorageFind(parentId);
temp
XMLload=
;
dhtmlObject
insertNewItem(parentId
cId
name
im
im
im
zST
chd
url);
if(dhtmlObject
parserExtension)dhtmlObject
parserExtension
_parseExtension(node
childNodes[i]
dhtmlObject
parserExtension
cId
parentId);
dhtmlObject
setItemColor(cId
aColor
sColor);
if((closeable==
)||(closeable==
))dhtmlObject
setItemCloseable(cId
closeable);
var zcall=dhtmlObject
_parseXMLTree(dhtmlObject
node
childNodes[i]
cId
);
if(zcall!=
)nodeAskingCall=zcall;
}
else
if((node
childNodes[i]
nodeType==
)&&(node
childNodes[i]
tagName ==
userdata
))
{
var name=node
childNodes[i]
getAttribute(
name
);
if((name)&&(node
childNodes[i]
childNodes[
])){
dhtmlObject
setUserData(parentId
name
node
childNodes[i]
childNodes[
]
data);
};
};
};
if(!level){
dhtmlObject
lastLoadedXMLId=parentId;
dhtmlObject
_redrawFrom(dhtmlObject);
dhtmlObject
XMLloadingWarning=
;
var chArr=dhtmlObject
setCheckList
split(
);
for(var n=
;n<chArr
length;n++)
if(chArr[n])dhtmlObject
setCheck(chArr[n]
);
if(nodeAskingCall!=
)dhtmlObject
selectItem(nodeAskingCall
true);
}
return nodeAskingCall;
};
dhtmlXTreeObject
prototype
_redrawFrom=function(dhtmlObject
itemObject){
if(!itemObject){
var tempx=dhtmlObject
_globalIdStorageFind(dhtmlObject
lastLoadedXMLId);
dhtmlObject
lastLoadedXMLId=
;
if(!tempx)return
;
}
else tempx=itemObject;
for(var i=
;i<tempx
childsCount;i++)
{
if(!itemObject)tempx
childNodes[lNode
parentNode
parentNode
style
display=
;
if(tempx
childNodes[i]
openMe==
)
for(var zy=
;zy<tempx
childNodes[i]
childNodes
length;zy++)
tempx
childNodes[lNode
childNodes[
]
childNodes[zy+
]
style
display=
;
dhtmlObject
_redrawFrom(dhtmlObject
tempx
childNodes[i]);
dhtmlObject
_correctLine(tempx
childNodes[i]);
dhtmlObject
_correctPlus(tempx
childNodes[i]);
};
dhtmlObject
_correctLine(tempx);
dhtmlObject
_correctPlus(tempx);
};
dhtmlXTreeObject
prototype
_createSelf=function(){
var div=document
createElement(
div
);
div
className=
containerTableStyle
;
div
style
width=this
width;
div
style
height=this
height;
this
parentObject
appendChild(div);
return div;
};
dhtmlXTreeObject
prototype
_xcloseAll=function(itemObject)
{
if(this
rootId!=itemObject
id)this
_HideShow(itemObject
);
for(var i=
;i<itemObject
childsCount;i++)
this
_xcloseAll(itemObject
childNodes[i]);
};
dhtmlXTreeObject
prototype
_xopenAll=function(itemObject)
{
this
_HideShow(itemObject
);
for(var i=
;i<itemObject
childsCount;i++)
this
_xopenAll(itemObject
childNodes[i]);
};
dhtmlXTreeObject
prototype
_correctPlus=function(itemObject){
var workArray=this
lineArray;
if((this
XMLsource)&&(!itemObject
XMLload))
{
var workArray=this
plusArray;
lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+itemO
bject
images[
];
}
else
try{
if(itemObject
childsCount)
{
if(lNode
childNodes[
]
childNodes[
]
style
display!=
none
)
{
var workArray=this
minusArray;
lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+itemO
bject
images[
];
}
else
{
var workArray=this
plusArray;
lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+itemO
bject
images[
];
}
}
else
{
lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+itemO
bject
images[
];
}
}
catch(e){};
var tempNum=
;
if(!itemObject
treeNod
treeLinesOn)lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+workArray[
];
else{
if(itemObject
parentObject)tempNum=this
_getCountStatus(itemObject
id
itemObject
parentObject);
lNode
childNodes[
]
childNodes[
]
childNodes[
]
childNodes[
]
src=this
imPath+workArray[tempNum];
}
};
dhtmlXTreeObject
prototype
_correctLine=function(itemObject){
var sNode=itemObject
parentObject;
try{
if(sNode)
if((this
_getLineStatus(itemObject
id
sNode)==
)||(!this
treeLinesOn))
{
for(var i=
;i<=itemObject
childsCount;i++)
{
lNode
childNodes[
]
childNodes[i]
childNodes[
]
style
backgroundImage=
;
lNode
childNodes[
]
childNodes[i]
childNodes[
]
style
backgroundRepeat=
;
}
}
else
for(var i=
;i<=itemObject
childsCount;i++)
{
lNode
childNodes[
]
childNodes[i]
childNodes[
]
style
backgroundImage=
url(
+this
imPath+
line
gif)
;
lNode
childNodes[
]
childNodes[i]
childNodes[
]
style
backgroundRepeat=
repeat
y
;
}
}
catch(e){};
};
dhtmlXTreeObject
prototype
_getCountStatus=function(itemId
itemObject){
try{
if(itemObject
childsCount<=
){if(itemObject
id==this
rootId)return
;else return
;}
if(lNode
childNodes[
]
childNodes[
]
nodem
id==itemId)if(!itemObject
id)return
;else return
;
if(lNode
childNodes[
]
childNodes[itemObject
childsCount]
nodem
id==itemId)return
;
}
catch(e){};
return
;
};
dhtmlXTreeObject
prototype
_getLineStatus =function(itemId
itemObject){
if(lNode
childNodes[
]
childNodes[itemObject
childsCount]
nodem
id==itemId)return
;
return
;
}
dhtmlXTreeObject
prototype
_HideShow=function(itemObject
mode){
if(((this
XMLsource)&&(!itemObject
XMLload))&&(!mode)){itemObject
XMLload=
;this
loadXML(this
XMLsource+getUrlSymbol(this
XMLsource)+
id=
+escape(itemObject
id));return;};
var Nodes=lNode
childNodes[
]
childNodes;var Count=Nodes
length;
if(Count>
){
if(((Nodes[
]
style
display!=
none
)||(mode==
))&&(mode!=
))node;else node;
for(var i=
;i<Count;i++)
Nodes[i]
style
display=nodestyle;
}
this
_correctPlus(itemObject);
}
dhtmlXTreeObject
prototype
_getOpenState=function(itemObject){
var z=lNode
childNodes[
]
childNodes;
if(z
length<=
)return
;
if(z[
]
style
display!=
none
)return
;
else return
;
}
dhtmlXTreeObject
prototype
onRowClick
=function(){
if(this
parentObject
treeNod
dblclickFuncHandler)if(!this
parentObject
treeNod
dblclickFuncHandler(this
parentObject
id))return
;
if((this
parentObject
closeble)&&(this
parentObject
closeble!=
))
this
parentObject
treeNod
_HideShow(this
parentObject);
else
this
parentObject
treeNod
_HideShow(this
parentObject
);
};
dhtmlXTreeObject
prototype
onRowClick=function(){
if(this
parentObject
treeNod
openFuncHandler)if(!this
parentObject
treeNod
openFuncHandler(this
parentObject
id
this
parentObject
treeNod
_getOpenState(this
parentObject)))return
;
if((this
parentObject
closeble)&&(this
parentObject
closeble!=
))
this
parentObject
treeNod
_HideShow(this
parentObject);
else
this
parentObject
treeNod
_HideShow(this
parentObject
);
};
dhtmlXTreeObject
prototype
onRowSelect=function(e
htmlObject
mode){
if(!htmlObject)htmlObject=this;
htmlObject
childNodes[
]
className=
selectedTreeRow
;
if(htmlObject
parentObject
scolor)htmlObject
parentOlor=htmlObject
parentObject
scolor;
if((htmlObject
parentObject
treeNod
lastSelected)&&(htmlObject
parentObject
treeNod
lastSelected!=
htmlObject))
{
htmlObject
parentObject
treeNod
lastSelected
childNodes[
]
className=
standartTreeRow
;
if(htmlObject
parentObject
treeNod
lastSelected
parentObject
acolor)htmlObject
parentObject
treeNod
lastSelected
parentOlor=htmlObject
parentObject
treeNod
lastSelected
parentObject
acolor;
}
htmlObject
parentObject
treeNod
lastSelected=htmlObject;
if(!mode){if(htmlObject
parentObject
actionHandler)htmlObject
parentObject
actionHandler(htmlObject
parentObject
id);}
};
dhtmlXTreeObject
prototype
_correctCheckStates=function(dhtmlObject){
if(!this
tscheck)return;
if(dhtmlObject
id==this
rootId)return;
var act=lNode
childNodes[
]
childNodes;
var flag
=
;var flag
=
;
if(act
length<
)return;
for(var i=
;i<act
length;i++)
if(act[i]
nodem
checkstate==
)flag
=
;
else if(act[i]
nodem
checkstate==
)flag
=
;
else{flag
=
;flag
=
;break;}
if((flag
)&&(flag
))this
_setCheck(dhtmlObject
notsure
);
else if(flag
)this
_setCheck(dhtmlObject
false);
else this
_setCheck(dhtmlObject
true);
this
_correctCheckStates(dhtmlObject
parentObject);
}
dhtmlXTreeObject
prototype
onCheckBoxClick=function(e){
if(this
treeNod
tscheck)
if(this
parentObject
checkstate==
)this
treeNod
_setSubChecked(false
this
parentObject);
else this
treeNod
_setSubChecked(true
this
parentObject);
else
if(this
parentObject
checkstate==
)this
treeNod
_setCheck(this
parentObject
false);
else this
treeNod
_setCheck(this
parentObject
true);
this
treeNod
_correctCheckStates(this
parentObject
parentObject);
if(this
treeNod
checkFuncHandler)return(this
treeNod
checkFuncHandler(this
parentObject
id
this
parentObject
checkstate));
else return true;
};
dhtmlXTreeObject
prototype
_createItem=function(acheck
itemObject
mode){
var table=document
createElement(
table
);
table
cellSpacing=
;table
cellPadding=
;
table
border=
;
if(this
hfMode)table
style
tableLayout=
fixed
;
table
style
margin=
;table
style
padding=
;
var tbody=document
createElement(
tbody
);
var tr=document
createElement(
tr
);
var td
=document
createElement(
td
);
td
className=
standartTreeImage
;
var img
=document
createElement(
img
);
img
border=
;td
appendChild(img
);img
style
padding=
;
var td
=document
createElement(
td
);
var inp=document
createElement(
img
);inp
checked=
;inp
src=this
imPath+this
checkArray[
];inp
style
width=
px
;inp
style
height=
px
;
if(!acheck)inp
style
display=
none
;
td
appendChild(inp);
td
width=
px
;
inp
onclick=this
onCheckBoxClick;
inp
treeNod=this;
inp
parentObject=itemObject;
var td
=document
createElement(
td
);
td
className=
standartTreeImage
;
var img=document
createElement(
img
);img
onmousedown=this
_preventNsDrag;
img
border=
;
if(!mode)img
src=this
imPath+this
imageArray[
];
td
appendChild(img);img
style
padding=
;img
style
margin=
;
if(this
timgen)
{img
style
width=
px
;img
style
height=
px
;}
else
{img
style
width=
px
;img
style
height=
px
;}
</script>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19197.html