tree.js
function getRank(rankNum)
{
var rankName="";
switch(rankNum)
{
case 1:
{
rankName="(普通会员)";
break;
}
case 2:
{
rankName="(一级会员)";
break;
}
case 3:
{
rankName="(二级会员)";
break;
}
case 4:
{
rankName="(三级会员)";
break;
}
}
return rankName;
}
function getContent(arrayCol)
{
var str="";
var imgPath=rootPath+"images/";
if(arrayCol.N_IS_SERVICE=="2")
{
imgPath+="fwzx.gif";
}else
{
switch(parseInt(arrayCol.N_STATE))
{
case 0:
{
imgPath+="wkt.gif";
break;
}
case 1:
{
imgPath+="kt.gif";
break;
}
}
}
if(arrayCol.N_STATE==2)
{
imgPath+="chuju.gif";
}
return str +="<img src='"+imgPath+"'/>"+arrayCol.V_USER_ID+getRank(parseInt(arrayCol.N_RANK));
}
function addNode(obj)
{
if(obj.sFlag==undefined && obj.isSon>0)
{
obj.sFlag=1;
ajaxuser.getUserTree(obj.sId,1,function(datas){
for(var i=0;i<datas.length;i++)
{
var chdNode=datas[i];
var tmpEle = new WebFXTreeItem(getContent(chdNode),chdNode.V_USER_ID,chdNode.IS_SON);
obj.add(tmpEle);
}
obj.toggle();
});
}else
{
obj.toggle();
}
}
function writeTree(tree)
{
document.write(tree);
}
function callBackUser(datas)
{
var rootNode=datas[0];
if (document.getElementById) {
var tree = new WebFXTree('Root');
tree.setBehavior('classic');
var a = new WebFXTreeItem(getContent(rootNode),rootNode.V_USER_ID,rootNode.IS_SON);
tree.add(a);
writeTree(tree);
}
}
//ajaxuser.getUserTree(userId,0,callBackUser);
// var s=[{V_USER_ID:"admin",IS_SON:1,N_IS_SERVICE:1,N_STATE:1,N_RANK:1}];
callBackUser(userInfo);
usertree.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>会员关系推荐图</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script src="<%=basePath%>/dwr/interface/ajaxuser.js"></script>
<script src="<%=basePath%>/dwr/engine.js"></script>
<script src="<%=basePath%>/dwr/util.js"></script>
<link type="text/css" rel="stylesheet"
href="<%=basePath%>css/xtree.css">
<script src="<%=basePath%>js/xtree.js"></script>
</head>
<body>
<div
style="position: absolute; width: 100%; top: 0px; left: 0px; height: 98%; padding: 5px; overflow: auto; background-color: #f0fff8">
<table
style="height: 23px; font-weight: bold; top: 0px; width: 50%; font-size: 12px; font-weight: bold; background-color: #f0fff8"
align="right">
<tr>
<td align="right">
说明:
<img src="<%=basePath%>/images/fwzx.gif" />
服务中心
<img src="<%=basePath%>/images/kt.gif" />
开通
<img src="<%=basePath%>/images/wkt.gif" />
未开通
<img src="<%=basePath%>/images/chuju.gif" />
出局
</td>
</tr>
</table>
<!-- js file containing the tree content, edit this file to alter the menu,
the menu will be inserted where this tag is located in the document -->
<script type="text/javascript">
var rootPath="<%=basePath%>";
var userId ="<%=request.getRemoteUser()%>";
var userInfo=[{V_USER_ID:"${userInfo[0].V_USER_ID}",IS_SON:${userInfo[0].IS_SON},N_IS_SERVICE:${userInfo[0].N_IS_SERVICE},N_STATE:${userInfo[0].N_STATE},N_RANK:${userInfo[0].N_RANK}}];
</script>
<script src="<%=basePath%>js/tree.js"></script>
</div>
</body>
</html>
然后再加入xtree的xtree.js文件
下载地址http://d.download.csdn.net/down/1783790/yaa2004