⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtmlxtree.js

📁 dhtmlxGrid 是跨浏览器的 JavaScript 表格控制组件(Grid Control)
💻 JS
📖 第 1 页 / 共 5 页
字号:
			this.dragger.removeDraggableItem(td3);
			if (this.dragAndDropOff) this.dragger.addDraggableItem(td3,this);
			td3.childNodes[0].className="standartTreeRow";
			td3.onclick=this.onRowSelect; td3.ondblclick=this.onRowClick2; 
			td1.previousSibling.onclick=this.onRowClick;

			this._correctLine(itemObject);
			this._correctPlus(itemObject);
			for (var i=0; i<itemObject.childsCount; i++) this._clearStyles(itemObject.childNodes[i]); 

	};
/**  
*     @desc: register node and all childs nodes
*     @type: private
*     @param: itemObject - node object
*     @topic: 2  
*/
	dhtmlXTreeObject.prototype._registerBranch=function(itemObject,oldTree){
	/*for (var i=0; i<itemObject.childsCount; i++)
		if (confirm(itemObject.childNodes[i].id)) return;*/
		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;				
	};
	
	
/**  
*     @desc: enable three state checkboxes
*     @beforeInit: 1
*     @param: mode - 1 - on, 0 - off;
*     @type: public
*     @topic: 0  
*/			
	dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode) { this.tscheck=convertStringToBoolean(mode); };
	




/**  
*     @desc: enable tree images
*     @beforeInit: 1
*     @param: mode - 1 - on, 0 - off;
*     @type: public
*     @topic: 0  
*/			
	dhtmlXTreeObject.prototype.enableTreeImages=function(mode) { this.timgen=convertStringToBoolean(mode); };
	
	
	
/**  
*     @desc: enable mode with fixed tables (look better, but hasn't horisontal scrollbar)
*     @beforeInit: 1
*     @param: mode - 1 - on, 0 - off;
*     @type: private
*     @topic: 0  
*/			
	dhtmlXTreeObject.prototype.enableFixedMode=function(mode) { this.hfMode=convertStringToBoolean(mode); };
	
/**  
*     @desc: hide checkboxes (all checkboxes in tree)
*     @type: public
*     @param: mode - enabled/disabled
*     @topic: 0  
*/
	dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode){ this.checkBoxOff=convertStringToBoolean(mode); };
/**
*     @desc: set default images for nodes (must be called before XML loading)
*     @type: public
*     @param: a0 - image for node without childrens;
*     @param: a1 - image for closed node;
*     @param: a2 - image for opened node  		  		  
*     @topic: 6  
*/
	dhtmlXTreeObject.prototype.setStdImages=function(image1,image2,image3){
						this.imageArray[0]=image1; this.imageArray[1]=image2; this.imageArray[2]=image3;};

/**  
*     @desc: enable/disable tree lines (parent-child threads)
*     @type: public
*     @param: mode - enable/disable tree lines
*     @topic: 6  
*/						
	dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
		this.treeLinesOn=convertStringToBoolean(mode);
	}

/**  
*     @desc: set images used for parent-child threads drawing
*     @type: public
*     @param: arrayName - name of array: plus, minus
*     @param: image1 - line crossed image
*     @param: image2 - image with top line
*     @param: image3 - image with bottom line
*     @param: image4 - image without line
*     @param: image5 - single root image
*     @topic: 6  
*/		
	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;
		}
	};

/**  
*     @desc: expand node
*     @param: itemId - identificator of node
*     @type: public
*     @topic: 4  
*/ 
	dhtmlXTreeObject.prototype.openItem=function(itemId){
		var temp=this._globalIdStorageFind(itemId);
		if (!temp) return 0;	
		else return this._openItem(temp);
	};

/**  
*     @desc: expand node
*     @param: item - tree node object
*     @type: private
*	  @editing: pro
*     @topic: 4  
*/ 
	dhtmlXTreeObject.prototype._openItem=function(item){
			this._HideShow(item,2);	
				if ((item.parentObject)&&(this._getOpenState(item.parentObject)<0))
					this._openItem(item.parentObject); 
	};
	
/**  
*     @desc: collapse node
*     @param: itemId - identificator of node
*     @type: public
*     @topic: 4  
*/ 
	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);		
	};
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
/**  
*     @desc: return node level (position in hierarchy)
*     @param: itemId - identificator of node
*     @type: public
*     @return: node level
*     @topic: 4  
*/
	dhtmlXTreeObject.prototype.getLevel=function(itemId){
		var temp=this._globalIdStorageFind(itemId);
		if (!temp) return 0;
		return this._getNodeLevel(temp,0);
	};
	
		

/**  
*     @desc: prevent node from closing
*     @param: itemId - identificator of node
*     @param: flag -  if 0 - node can't be closed, else node can be closed
*     @type: public
*     @topic: 4  
*/ 
	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;
	};
	
	/**  
*     @desc: recursive function used fo node level calculation
*     @param: itemObject - pointer to node object
*     @param: count - counter of levels		  
*     @type: private
*     @topic: 4  
*/	
	dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){
		if (itemObject.parentObject) return this._getNodeLevel(itemObject.parentObject,count+1);
		return(count);
	};
	
	/**  
*     @desc: return count of childrens
*     @param: itemId - identificator of node
*     @type: public
*     @return: count of child items; true - for not loaded branches
*     @topic: 4
*/
	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;
			};
	};
	


	
/**
*     @desc: set new node text (HTML allowed)
*     @param: itemId - identificator of node
*     @param: newLabel - node text
*     @type: public
*     @topic: 6
*/
	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||"";
	};
/**  
*     @desc: refresh tree branch from xml (XML with description of child nodes rerequested from server)
*     @param: itemId - identificator of node, if not defined tree super root used.
*     @type: public
*     @topic: 6  
*/	
	dhtmlXTreeObject.prototype.refreshItem=function(itemId){
		if (!itemId) itemId=this.rootId;
		var temp=this._globalIdStorageFind(itemId);
		this.deleteChildItems(itemId);
		this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"id="+escape(itemId));
	};	
	
	/**  
*     @desc: set item images
*     @param: itemId - identificator of node
*     @param: image1 - node without childrens image
*     @param: image2 - closed node image  		  
*     @param: image3 - open node image 		  
*     @type: public
*     @topic: 6  
*/		
	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);
	};
/**  
*     @desc: set item images
*     @param: itemId - identificator of node
*     @param: image1 - node without childrens image or closed node image (if image2 specified)
*     @param: image2 - open node image (optional)		  
*     @type: public
*     @topic: 6  
*/	
	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);
	};
	
	
/**  
*     @desc: Returns the list of all children items from the next level of tree, separated by commas.
*     @param: itemId - identificator of node
*     @type: public
*     @return: list of all children items from the next level of tree, separated by commas.
*     @topic: 6  
*/	
	dhtmlXTreeObject.prototype.getSubItems =function(itemId)
	{
		var temp=this._globalIdStorageFind(itemId);
		if (!temp) return 0;

		var z="";
		for (i=0; i<temp.childsCount; i++)
			if (!z) z=temp.childNodes[i].id;
				else z+=","+temp.childNodes[i].id;
		return z;
	};
/**  
*     @desc: Returns the list of all children items from all next levels of tree, separated by commas.
*     @param: itemId - identificator of node
*     @type: public
*     @return: list of all children items from all next levels of tree, separated by commas
*     @topic: 6  
*/	
	dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){
		return this._getAllSubItems(itemId);
	}
	
/**  
*     @desc: Returns the list of all children items from all next levels of tree, separated by commas.
*     @param: itemId - identificator of node
*     @type: private
*     @topic: 6
*/	
	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+=","+temp.childNodes[i].id;
			var zb=this._getAllSubItems(0,z,temp.childNodes[i])
			if (zb) z+=","+zb;
			}
		return z;
	};	
	

	
/**  
*     @desc: select node ( and optionaly fire onselect event)
*     @type: public
*     @param: itemId - node identificator
*     @param: mode - If true, script function for selected node will be called.
*     @topic: 1
*/		
	dhtmlXTreeObject.prototype.selectItem=function(itemId,mode){ 
		mode=convertStringToBoolean(mode);
		var temp=this._globalIdStorageFind(itemId);
		if (!temp) return 0;
		if (this._getOpenState(temp.parentObject)==-1)
			this.openItem(itemId);
		//temp.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],mode);
		if (mode)
			this.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);
		else
			this.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true);
	};
	
/**  
*     @desc: retun selected node text
*     @type: public
*     @return: text of selected node
*     @topic: 1  
*/	
	dhtmlXTreeObject.prototype.getSelectedItemText=function()
	{
		if (this.lastSelected)
		return this.lastSelected.parentObject.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML;
		else return ("");
	};




/**  
*     @desc: correct childNode list after node deleting
*     @type: private
*     @param: Count - childNodes collection length		  
*     @param: Nodes - childNodes collection
*     @topic: 4  
*/	
	dhtml

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -