日期:2014-05-17  浏览次数:21319 次

请教高手,关于树型结构问题,有些困惑!
我从网上下载了个树型结构原文件,现在看不懂.js文件,麻烦帮助我解释一下哈,
主要是我想实现其中一个功能,
因为现在这个树,默认是全部关闭的,缩在一个根下的,点后才能出现一级类别,

我想改成,默认情况下,就显示一级类别,请问大家,下面什么地方需要修改,
真的希望有高手们帮助我哈,十分谢谢!

index.asp文件,调用的代码
<script   language= "javascript "   type= "text/javascript "   src= "dhATV.js "> </script>
<script   language= "javascript "   type= "text/javascript ">
function   vc(cs){
window.open( 'test.asp?classid= '+cs);
}
</script>

<script   language= "javascript "   type= "text/javascript ">
//定义对象实例
var   dhATV   =   new   dhAjaxTreeView();
//返回对象实例名
dhATV.treeTagName   =   "dhATV ";
//设置根节点文字
dhATV.rootText   =   "在线教育系统 ";
//设置结点文字大小
dhATV.textsize   =   "12px ";
//设置图标文件夹
dhATV.icoFolder   =   "folder ";
//设置请求地址
dhATV.postUrl   =   "getMenu.asp?menuid=0 ";
//设置节点事件
dhATV.nodeEvent   =   function(cs){vc(cs);}
//加载树根节点
dhATV.setup(document.getElementById( "tree "));
</script>

以下是dhATV.js   代码,看改什么地方,可以实现我想要的功能
/**   Mozilla兼容MsIE脚本,stylesheet扩展部分。
  *   o   stylesheet.addRule()
  */
(function   ()   {
if   (!   window.CSSStyleSheet)   return;
function   _ss_GET_rules_   ()   {
return   this.cssRules;
}
var   _ss   =   CSSStyleSheet.prototype;
_ss.addRule   =   function(sSelector,   sRule)   {
this.insertRule(sSelector   +   "{ "   +   sRule   +   "} ",   this.cssRules.length);
}
_ss.__defineGetter__( "rules ",   _ss_GET_rules_);
})();

function   dhAjaxTreeView(){
//author:dh20156
var   dh   =   this;
//定义实例名
this.treeTagName   =   null;
//定义结点图标文件夹
this.icoFolder   =   "folder ";
//定义根结点文字
this.rootText   =   "Root ";
//定义结点文字大小
this.textsize   =   "12px ";
//定义请求地址
this.postUrl   =   "getMenu.asp?menuid= ";
//定义客户端指定结点事件
this.nodeEvent   =   function(cs){alert(cs);};
//定义当前选定结点
var   selectedflag   =   null;
//点击节点事件
this.clickNode   =   function(obj){
var   otype   =   obj.className;
otype   =   otype.toLowerCase();
if(otype!= "childvalue "   &&   otype!= "lastvalue "){
var   ocsd   =   obj.childNodes[4].style.display;
ocsd== "block "?this.hideNode(obj):this.showNode(obj);
}else{
var   fid   =   obj.getAttribute( "fid ");
this.nodeEvent(fid);
}
}
//关闭节点
this.hideNode   =   function   (obj){
obj.childNodes[4].style.display   =   "none ";
this.setIcon(obj, "close ");
}
//展开节点
this.showNode   =   function   (obj,otype){
obj.childNodes[4].style.display   =   "block ";
var   nl   =   obj.childNodes[4].childNodes.length;
if(nl==0){
this.getNode(obj);
}
this.setIcon(obj, "open ");