jquery easyui递归实现用户组树实例

2014-01-10 22:03:36   2309
/**
* 用户组管理_所有用户组树
* @param
* @return
*/
public List<TreeNode> getUserAllGroupTree(){
List<TreeNode> treeNodeList=new ArrayList<TreeNode>();
TreeNode rootNode=new TreeNode("root","所有用户组");
List<TreeNode> groupNodeList=new ArrayList<TreeNode>();
List<KeyValueObject> userGroupList = getUserGroupData();//获取第一级用户组
for(KeyValueObject userRoleGroup : userGroupList){
TreeNode groupNode = new TreeNode("Group_"+userRoleGroup.getKey(),userRoleGroup.getValue());
groupNode.setIconCls("icon-line");
groupNodeList.add(groupNode);
recursionUserGroup(groupNode,userRoleGroup);
}
rootNode.setChildren(groupNodeList);
treeNodeList.add(rootNode);
return treeNodeList;
}
/*
* 递归获取用户组
*/
public void recursionUserGroup(TreeNode childGroupNode,KeyValueObject userChildGroup){
List<TreeNode> userChildList1 = new ArrayList<TreeNode>();
List<KeyValueObject> userChildGroupList1 = getUserChildGroupData(userChildGroup.getKey());
if(userChildGroupList1.size()>0){
for(KeyValueObject userChildGroup1 : userChildGroupList1){
TreeNode childGroupNode1 = new TreeNode("Group_"+userChildGroup1.getKey(),userChildGroup1.getValue());
childGroupNode1.setIconCls("icon-line");
userChildList1.add(childGroupNode1);
recursionUserGroup(childGroupNode1,userChildGroup1);
}
}
if(userChildList1.size()>0){
childGroupNode.setChildren(userChildList1);
}
}