前台JSP 没什么难的 调用onBeforeExpand 点击节点触发下一节点
<ul id="tt" data-options="animate:true,lines:false" ></ul>
$('#tt').tree({
checkbox: false,
url: contextRoot + 'wf/WfDesignAction!TreeList.action?currentId=-1',//调用action返回json数据
onBeforeExpand:function(node,param){
if(node){
$('#tt').tree('options').url = contextRoot + 'wf/WfDesignAction!TreeList.action?currentId='+ node.id;
}
},
onClick:function(node){
alert(node.id);
}
});
后台action
public String TreeList() throws IOException{
try{
String sessionId = this.getSessionID();
String method = "wf.getChildNodes";
Map<String, Object> map = new HashMap<String, Object>();
map.put("Id", currentId);
String paramValue = this.Object2JSon(map);
String result = wfDesignService.TreeList(sessionId, method, paramValue);
List<Object> List = JsonProcessUtil.rowsJsonToBean(result,TreeNodeEntity.class);
List<TreeNodeEntity> searchList = new ArrayList<TreeNodeEntity>();
//以下才是重点 前面是我的项目调用的一些方法而已 重点是通过后台返回的list 把得到的list进行字符串拼接成EasyUi能够识别的json格式
for( Object item : List ) {
searchList.add((TreeNodeEntity)item);
}
String str = "[";
if(searchList!=null&&searchList.size()>0){
for(TreeNodeEntity treeNodeEntity:searchList){
str +="{";
str+="\"id\":\""+treeNodeEntity.getId()+"\",\"text\":\""+treeNodeEntity.getText()+"\",\"state\":\"closed\" },";
}
str=str.substring(0, str.length()-1);
str=str+"]";
System.out.println(str);
}else{
str="[]";
}
this.setJson(str);
}catch(Exception e){
e.printStackTrace();
}
return Const.ACTION_JSON;
}