// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
//--在该处添加以下语句,目的是在用户点击
//--node时向opener添加该node相关信息
this.allName = cn.name;
this.allId = cn.id;
this.parentNodePath(cn.pid);
//执行用户语法
eval(window.dialogArguments.imaginaryOperate);
if(cn.level == 'C' || cn.level == 'c'){
self.close();
}
//=============================================
//1、将dtree的节点对象保存到数组对象
regions = [];
for(i = 0;i < d.aNodes.length;i ++){
regions[regions.length] = new Region(d.aNodes[i].id,d.aNodes[i].pid,d.aNodes[i].name,d.aNodes[i].level);
}
//2、销毁dtree的节点对象
d.aNodes = [];
//3、获得点击节点的子节点
sRegions = country.getSonRegionsByPid(cn.id);
//4、将子节点加入到regions中,注意已有就不应再加入
for(i = 0;i < sRegions.length;i ++){
flag = true;
for(j = 0;j < regions.length;j ++){
if(sRegions[i].id == regions[j].id){
flag = false;
break;
}
}
if(flag) regions[regions.length] = sRegions[i];
}
//5、重新构造dtree
for(i = 0;i<regions.length;i++){
d.add(regions[i].id,regions[i].pid,regions[i].name,regions[i].level);
}
document.getElementById('dtree').innerHTML = d.toString();
//6、打开被点击的点
d.openTo(cn.id);
//=============================================
/*
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
*/
}; |