webfxtree

解决方案 »

  1.   

    [code=JScript ]
    var roots;
    function treeDataIni(xmlfile,rootTitle){
    if (document.getElementById) {

    roots = new WebFXTree(rootTitle,'','',imgpath+'pageroot.gif',imgpath+'pageroot.gif');
    roots.setBehavior('classic');
    roots.objectid = "ROOT";
    loadPagePick(roots,xmlfile);//调用加载子节点函数
    document.write(roots);
    }
    }//确定选择
    function cmd_ok(){
    if (roots.getSelected()==null) {
    alert("请选择一项,再进行操作。");
    return;
    }
    if (roots.getSelected().objectid=="ROOT") {
    alert("根节点不能进行操作,请选择其他项。");
    return;
    }
    //alert(roots.getSelected().objectid+" --- "+roots.getSelected().text);
    dialogArguments.document.getElementById("ORGANPARENTID").value = roots.getSelected().objectid;

    dialogArguments.document.getElementById("ORGANPARENTNAME").value = roots.getSelected().text;
    window.close();
    }
    //加载页面(目录);
    function loadPagePick(frms,xmlfile){
    var sURL=xmlfile;
    xpo.setURL(webroot+sURL);
    xpo.post();
    var infolist=xpo.getResultNodes("rs/记录");
    var levelPoint = 4;//级别的长度;4位一级;

    for(i=0;i<infolist.length;i++){
       objectid = infolist[i].get("ORGANID");
       nodeid=infolist[i].get("ORGANID");
    nodename=infolist[i].get("ORGANNAME");
    type = infolist[i].get("ORGANLEVEL");
    coding = infolist[i].get("ORGANID");

    surl = webroot+"/pages/home/noinfo.jsp";
    target = "inFrmWindow";


    var description = infolist[i].get("ORGANDES");

    var nodeIcon = "foldericon.png";
    var a = new WebFXTreeItem(nodename,'','',imgpath+nodeIcon,imgpath+nodeIcon);//包;
    a.action="javascript:expNodes('"+nodeid+"','"+nodename+"');";
                //openTarget="#";
    a.objectid=objectid;
    a.coding = coding;
    a.description=description;
    frms.add(a);
    }
    }//打开的页面;
    function openTarget(surl,starget){
    //window.open(surl,starget);
    }//展开的子节点; function expNodes(parentid,parentname){


    if (roots.getSelected().childNodes.length>0) return;

    var sURL="/interface4j/appcomponent/organ/IA.do?INTERFACE=appcomponent.purview.organ&CMDTYPE=1&PARENTID="+parentid;
    xpo.setURL(webroot+sURL);
    xpo.post();
    //alert(xpo.getResultStr());
    var infolist=xpo.getResultNodes("rs/记录");

    if (infolist.length<1){
    //alert("没有子节点了!");
    //alert(roots.getSelected()+" --- "+roots.getSelected().id);//.parentElement.id);srcElement
    document.getElementById(roots.getSelected().id+"-icon").src = imgpath+"view.gif";
    return;
    }
    var eSize = roots.getSelected().childNodes.length;
    //alert(eSize);
    var eNodes = new Array(); 
    for(i=0;i<eSize;i++){
    eNodes[i] = roots.getSelected().childNodes[i].objectid; 
    //alert(roots.getSelected().childNodes[i].objectid);
    }

    var eFlg = false;
    for(i=0;i<infolist.length;i++){
       eFlg = true;
       objectid = infolist[i].get("ORGANID");
       for(e=0;e<eNodes.length;e++){
       if (objectid==eNodes[e]){
       eFlg = false;
       }
       }
      
       if (eFlg){
       nodeid=infolist[i].get("ORGANID");
    nodename=infolist[i].get("ORGANNAME");
    type = infolist[i].get("ORGANLEVEL");
    coding = infolist[i].get("ORGANID");

    surl = webroot+"/pages/home/noinfo.jsp";
    target = "inFrmWindow";

    var description = infolist[i].get("ORGANDES");
    var nodeIcon = "foldericon.png";
    var b = new WebFXTreeItem(nodename,'','',imgpath+nodeIcon,imgpath+nodeIcon);
                   // b.action="javascript:expNodes('"+nodeid+"','"+nodename+"');";
        b.action="javascript:expNodes('"+nodeid+"','"+nodename+"');";
    b.objectid=objectid;
    b.coding = coding;
    b.description=description;
    roots.getSelected().add(b);
    }

    }
    roots.expandChildren();
    }[/code]慢慢看啊!