var HK_TreeNode = function(pNode){
var me = this;
var nodeValue = "";
var nodeImage = document.createElement("img");
var nodeElement = document.createElement("div");
var nodeText = document.createElement("div");
var childLayout = document.createElement("div");
nodeElement.appendChild(nodeImage);
nodeElement.appendChild(nodeText);
nodeElement.appendChild(childLayout);
nodeImage.src="images/plus.png";
nodeImage.className = "tree_nodeimage";
nodeText.className = "tree_nodetext";
childLayout.className = "tree_nodelayout";
childLayout.style.display = "none";
var nodeIndex = -1;
var parentNode = null;
var level = 0;
var items = new Array();
if(parentNode!=null){
level = pNode.level + 1;
parentNode = pNode;
}
this.tree = null;
this.data = null;
this.setActive = function(){
var activeNode = this.tree.activeNode;
if(activeNode!=null){
activeNode.deActive();
}
nodeText.className = "tree_nodetextActive";
this.tree.activeNode = this;
}
this.deActive = function(){
this.tree.activeNode = null;
nodeText.className = "tree_nodetext";
}
this.appendChild = function(node){
nodeIndex = items.push(node);
childLayout.appendChild(node.getElement());
nodeImage.src="images/plus.gif";
}
this.expand = function(){
if(childLayout.style.display != "none"){
nodeImage.src="images/plus.gif";
childLayout.style.display = "none";
}else{
if(items.length>0){
nodeImage.src="images/plusExpand.gif";
childLayout.style.display = "";
}
}
}
this.getCount = function(){
return items.length;
}
this.getLevel = function(){
return level;
}
this.setParentNode = function(node){
parentNode = node;
node.appendChild(nodeElement);
}
this.getParentNode = function(){
return node;
}
this.getElement = function(){
return nodeElement;
}
this.getImageElement = function(){
return nodeImage;
}
this.getTextElement = function(){
return nodeText;
}
this.setText = function(value){
nodeText.innerText = value;
}
this.getText = function(){
return nodeText.innerText;
}
this.setValue = function(value){
nodeValue = value;
this.setText(value);
}
this.getValue = function(){
return value;
}
function onnodeclick(){
me.expand();
}
function onnodetextclick(){
me.setActive();
}
function ontextdblclick(){
me.expand();
}
function onselect(){
return false;
}
nodeElement.attachEvent("onselectstart",onselect);
nodeText.attachEvent("onclick",onnodetextclick);
nodeText.attachEvent("ondblclick",ontextdblclick);
nodeImage.attachEvent("onclick",onnodeclick);
}
var HK_Tree = function(){
var me = this;
var layout = document.createElement("div");
var items = new Array();
var map = new Object();
var root = new Array();
var activeNode = null;
this.xml = null;
this.parent = null;
this.primaryField = "";
this.parentField = "";
this.valueField = "";
this.textField = "";
this.activeNode = null;
this.appendNode = function(parentNode){
var node = new HK_TreeNode(parentNode);
if(parentNode!=null){
parentNode.appendChild(node);
}else{
layout.appendChild(node.getElement());
root.push(node);
}
node.tree = this;
items.push(node);
return node;
}
this.getNodeByIndex = function(index){
if(items[i]!=undefined){
return items[i];
}
return null;
}
this.getNodeByName = function(name){
if(map[name]!=undefined){
return map[name];
}
return null;
}
this.getCount = function(){
return items.length;
}
this.laodxml = function(){
}
this.databand = function(){
var oRows = this.xml.getElementsByTagName("Row");
var oCol,oCells,oRow;
for(var i=0;i<oRows.length;i++){
var parentId = oRows[i].selectSingleNode("./field[@name='"+this.parentField+"']");
var nodeId = oRows[i].selectSingleNode("./field[@name='"+this.primaryField+"']");
var nodeValue = oRows[i].selectSingleNode("./field[@name='"+this.valueField+"']");
var nodeText = oRows[i].selectSingleNode("./field[@name='"+this.textField+"']");
if(parentId!=null&&nodeId!=null){
var node = this.appendNode(this.getNodeByName(parentId.text));
node.data = oRows[i].xml;
if(nodeValue!=null){
node.setValue(nodeValue.text);
}
if(nodeText!=null){
node.setText(nodeText.text);
}
map[nodeId.text] = node;
}
}
this.ondataband();
}
this.init = function(){
this.parent.appendChild(layout);
}
this.ondataband = function(){};
}
var tree = new HK_Tree();
tree.parent = document.getElementById("treepanel");
tree.primaryField = "unitId";
tree.parentField = "parentUnitId";
tree.valueField = "name";
tree.textField = "name";
tree.init();
今天下午完成的,发上来给大家看看
- 描述: 图片
- 大小: 13.5 KB
- Script.rar (19.7 KB)
- 描述: 里面还有树,TAB页,GRID,WEBSERVICE
只支持IE
- 下载次数: 701
分享到:
相关推荐
js树形控件js树形控件js树形控件js树形控件js树形控件js树形控件js树形控件js树形控件js树形控件js树形控件
使用labview对树形控件进行常规操作,进行拖曳和移动
java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件java树形控件
树形 权限管理 权限管理系统 树形控件。
labVIEW 实现树形控件的值拖拽的另一个树形控件中,任意形成节点
MFC中,动态添加、删除树形控件的节点,获取树形控件的选中项,绝对经典 !希望对你有所帮助!
在树形控件中插入背景图
本文介绍了VC中常用的树形控件使用方法。
jquery超漂亮树形控件
MFC中创建可编辑节点的树形控件绝对经典! 希望对你有所帮助!
常用树形控件,有样例,一看即懂。常用树形控件,有样例,一看即懂。
好用的vb树形控件,我找了好久的 axtree控件
vc树形控件
树形控件的增删改查树形控件的增删改查 树形控件的增删改查树形控件的增删改查
JavaScript树形控件实现无限级树形菜单
通过labview的树形控件来选择并编辑数据,同时将选择的数据显示在右侧的波形图表中。整个界面可根据用户需求自动缩放大小。
关于树形控件方面的工具 关于树形控件方面的工具 关于树形控件方面的工具
C/C++ MFC CListCtrl列表控件和CTreeCtrl树控件的完美结合,对话框模式的完整程序,有VC6.0 VS2008,VS2010的工程文件
经典树形控件,结合ajax和json技术。
Android使用ListView实现一个高性能无限层级显示的树形控件.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。