📄 dhtmlxtree.js
字号:
td1.previousSibling.onclick=this.onRowClick;
this._correctLine(itemObject);
this._correctPlus(itemObject);
for(var i=0;i<itemObject.childsCount;i++)this._clearStyles(itemObject.childNodes[i]);
};
dhtmlXTreeObject.prototype._registerBranch=function(itemObject,oldTree){
itemObject.id=this._globalIdStorageAdd(itemObject.id,itemObject);
itemObject.treeNod=this;
if(oldTree)oldTree._globalIdStorageSub(itemObject.id);
for(var i=0;i<itemObject.childsCount;i++)
this._registerBranch(itemObject.childNodes[i],oldTree);
return 0;
};
dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode){this.tscheck=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.setOnMouseInHandler=function(func){
this.ehlt=true;
if(typeof(func)=="function")this._onMSI=func;else this.aFunc=eval(func);};
dhtmlXTreeObject.prototype.setOnMouseOutHandler=function(func){
this.ehlt=true;
if(typeof(func)=="function")this._onMSO=func;else this.aFunc=eval(func);};
dhtmlXTreeObject.prototype.enableTreeImages=function(mode){this.timgen=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.enableFixedMode=function(mode){this.hfMode=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode,hidden){this.checkBoxOff=convertStringToBoolean(mode);this.cBROf=(!(this.checkBoxOff||convertStringToBoolean(hidden)));};
dhtmlXTreeObject.prototype.setStdImages=function(image1,image2,image3){
this.imageArray[0]=image1;this.imageArray[1]=image2;this.imageArray[2]=image3;};
dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
this.treeLinesOn=convertStringToBoolean(mode);
}
dhtmlXTreeObject.prototype.setImageArrays=function(arrayName,image1,image2,image3,image4,image5){
switch(arrayName){
case "plus": this.plusArray[0]=image1;this.plusArray[1]=image2;this.plusArray[2]=image3;this.plusArray[3]=image4;this.plusArray[4]=image5;break;
case "minus": this.minusArray[0]=image1;this.minusArray[1]=image2;this.minusArray[2]=image3;this.minusArray[3]=image4;this.minusArray[4]=image5;break;
}
};
dhtmlXTreeObject.prototype.openItem=function(itemId){
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
else return this._openItem(temp);
};
dhtmlXTreeObject.prototype._openItem=function(item){
if((this._spnFH)&&(!this._spnFH(item.id,this._getOpenState(item))))return 0;
this._HideShow(item,2);
if(this._epnFH)
if(!this.xmlstate)
this._epnFH(item.id,this._getOpenState(item));
else{
this._oie_onXLE=this.onXLE;
this.onXLE=this._epnFHe;
}
if((item.parentObject)&&(this._getOpenState(item.parentObject)<0))
this._openItem(item.parentObject);
};
dhtmlXTreeObject.prototype.closeItem=function(itemId){
if(this.rootId==itemId)return 0;
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
if(temp.closeble)
this._HideShow(temp,1);
};
dhtmlXTreeObject.prototype.getLevel=function(itemId){
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
return this._getNodeLevel(temp,0);
};
dhtmlXTreeObject.prototype.setItemCloseable=function(itemId,flag)
{
flag=convertStringToBoolean(flag);
if((itemId)&&(itemId.span))
var temp=itemId;
else
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
temp.closeble=flag;
};
dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){
if(itemObject.parentObject)return this._getNodeLevel(itemObject.parentObject,count+1);
return(count);
};
dhtmlXTreeObject.prototype.hasChildren=function(itemId){
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
else
{
if((this.XMLsource)&&(!temp.XMLload))return true;
else
return temp.childsCount;
};
};
dhtmlXTreeObject.prototype._getLeafCount=function(itemNode){
var a=0;
for(var b=0;b<itemNode.childsCount;b++)
if(itemNode.childNodes[b].childsCount==0)a++;
return a;
}
dhtmlXTreeObject.prototype.setItemText=function(itemId,newLabel,newTooltip)
{
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
temp.label=newLabel;
temp.span.innerHTML=newLabel;
temp.span.parentNode.title=newTooltip||"";
};
dhtmlXTreeObject.prototype.getItemTooltip=function(itemId){
var temp=this._globalIdStorageFind(itemId);
if(!temp)return "";
return(temp.span.parentNode.title||"");
};
dhtmlXTreeObject.prototype.refreshItem=function(itemId){
if(!itemId)itemId=this.rootId;
var temp=this._globalIdStorageFind(itemId);
this.deleteChildItems(itemId);
this._loadDynXML(itemId);
};
dhtmlXTreeObject.prototype.setItemImage2=function(itemId,image1,image2,image3){
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
temp.images[1]=image2;
temp.images[2]=image3;
temp.images[0]=image1;
this._correctPlus(temp);
};
dhtmlXTreeObject.prototype.setItemImage=function(itemId,image1,image2)
{
var temp=this._globalIdStorageFind(itemId);
if(!temp)return 0;
if(image2)
{
temp.images[1]=image1;
temp.images[2]=image2;
}
else temp.images[0]=image1;
this._correctPlus(temp);
};
dhtmlXTreeObject.prototype.getSubItems =function(itemId)
{
var temp=this._globalIdStorageFind(itemId,0,1);
if(!temp)return 0;
var z="";
for(i=0;i<temp.childsCount;i++){
if(!z)z=temp.childNodes[i].id;
else z+=this.dlmtr+temp.childNodes[i].id;
}
return z;
};
dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
{
var z="";
for(var i=0;i<node.childsCount;i++)
{
if((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
{
if(node.childNodes[i].unParsed)
var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
else
var zb=this._getAllScraggyItems(node.childNodes[i])
if(zb)
if(z)z+=this.dlmtr+zb;
else z=zb;
}
else
if(!z)z=node.childNodes[i].id;
else z+=this.dlmtr+node.childNodes[i].id;
}
return z;
};
dhtmlXTreeObject.prototype._getAllFatItems =function(node)
{
var z="";
for(var i=0;i<node.childsCount;i++)
{
if((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
{
if(!z)z=node.childNodes[i].id;
else z+=this.dlmtr+node.childNodes[i].id;
if(node.childNodes[i].unParsed)
var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
else
var zb=this._getAllFatItems(node.childNodes[i])
if(zb)z+=this.dlmtr+zb;
}
}
return z;
};
dhtmlXTreeObject.prototype._getAllSubItems =function(itemId,z,node)
{
if(node)temp=node;
else{
var temp=this._globalIdStorageFind(itemId);
};
if(!temp)return 0;
z="";
for(var i=0;i<temp.childsCount;i++)
{
if(!z)z=temp.childNodes[i].id;
else z+=this.dlmtr+temp.childNodes[i].id;
var zb=this._getAllSubItems(0,z,temp.childNodes[i])
if(zb)z+=this.dlmtr+zb;
}
return z;
};
dhtmlXTreeObject.prototype.selectItem=function(itemId,mode,preserve){
mode=convertStringToBoolean(mode);
var temp=this._globalIdStorageFind(itemId);
if((!temp)||(!temp.parentObject))return 0;
if(this._getOpenState(temp.parentObject)==-1)
if(this.XMLloadingWarning)
temp.parentObject.openMe=1;
else
this._openItem(temp.parentObject);
var ze=null;
if(preserve){
ze=new Object;ze.ctrlKey=true;
if(temp.i_sel)ze.skipUnSel=true;
}
if(mode)
this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);
else
this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true);
};
dhtmlXTreeObject.prototype.getSelectedItemText=function()
{
var str=new Array();
for(var i=0;i<this._selected.length;i++)str[i]=this._selected[i].span.innerHTML;
return(str.join(this.dlmtr));
};
dhtmlXTreeObject.prototype._compressChildList=function(Count,Nodes)
{
Count--;
for(var i=0;i<Count;i++)
{
if(Nodes[i]==0){Nodes[i]=Nodes[i+1];Nodes[i+1]=0;}
};
};
dhtmlXTreeObject.prototype._deleteNode=function(itemId,htmlObject,skip){
if(!skip){
this._globalIdStorageRecSub(htmlObject);
}
if((!htmlObject)||(!htmlObject.parentObject))return 0;
var tempos=0;var tempos2=0;
if(htmlObject.tr.nextSibling)tempos=htmlObject.tr.nextSibling.nodem;
if(htmlObject.tr.previousSibling)tempos2=htmlObject.tr.previousSibling.nodem;
var sN=htmlObject.parentObject;
var Count=sN.childsCount;
var Nodes=sN.childNodes;
for(var i=0;i<Count;i++)
{
if(Nodes[i].id==itemId){
if(!skip)sN.htmlNode.childNodes[0].removeChild(Nodes[i].tr);
Nodes[i]=0;
break;
}
}
this._compressChildList(Count,Nodes);
if(!skip){
sN.childsCount--;
}
if(tempos){
this._correctPlus(tempos);
this._correctLine(tempos);
}
if(tempos2){
this._correctPlus(tempos2);
this._correctLine(tempos2);
}
if(this.tscheck)this._correctCheckStates(sN);
};
dhtmlXTreeObject.prototype.setCheck=function(itemId,state){
var sNode=this._globalIdStorageFind(itemId,0,1);
if(!sNode)return;
if(state==="unsure")
this._setCheck(sNode,state);
else
{
state=convertStringToBoolean(state);
if((this.tscheck)&&(this.smcheck))this._setSubChecked(state,sNode);
else this._setCheck(sNode,state);
}
if(this.smcheck)
this._correctCheckStates(sNode.parentObject);
};
dhtmlXTreeObject.prototype._setCheck=function(sNode,state){
if(((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
if(this._frbtrs){
if(this._frbtrL)this._setCheck(this._frbtrL,0);
this._frbtrL=sNode;
}else
for(var i=0;i<sNode.parentObject.childsCount;i++)
this._setCheck(sNode.parentObject.childNodes[i],0);
var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
if(state=="unsure")sNode.checkstate=2;
else if(state)sNode.checkstate=1;else sNode.checkstate=0;
if(sNode.dscheck)sNode.checkstate=sNode.dscheck;
z.src=this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate];
};
dhtmlXTreeObject.prototype.setSubChecked=function(itemId,state){
var sNode=this._globalIdStorageFind(itemId);
this._setSubChecked(state,sNode);
this._correctCheckStates(sNode.parentObject);
}
dhtmlXTreeObject.prototype._setSubChecked=function(state,sNode){
state=convertStringToBoolean(state);
if(!sNode)return;
if(((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
for(var i=0;i<sNode.parentObject.childsCount;i++)
this._setSubChecked(0,sNode.parentObject.childNodes[i]);
if(sNode._r_logic||this._frbtr)
this._setSubChecked(state,sNode.childNodes[0]);
else
for(var i=0;i<sNode.childsCount;i++)
{
this._setSubChecked(state,sNode.childNodes[i]);
};
var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
if(state)sNode.checkstate=1;
else sNode.checkstate=0;
if(sNode.dscheck)sNode.checkstate=sNode.dscheck;
z.src=this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate];
};
dhtmlXTreeObject.prototype.isItemChecked=function(itemId){
var sNode=this._globalIdStorageFind(itemId);
if(!sNode)return;
return sNode.checkstate;
};
dhtmlXTreeObject.prototype.deleteChildItems=function(itemId)
{
var sNode=this._globalIdStorageFind(itemId);
if(!sNode)return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -