Html内容:- <fieldset style="height: 350px;">
- <ul id="taskTree" style="height:400px;width:250px;overflow: auto;"></ul>
- </fieldset>
js内容:
- $('#taskTree').tree({
- checkbox: false,
- url: url,
- animate:true,
- lines:true,
- onClick:function(node){
- alert(node.text);
- },
- onBeforeExpand:function(node,param){
- $('#taskTree').tree('options').url = ctx + "/rims/rescue/loadRescueTaskTreeRootNodes.do?parentId="+node.id;
- }
- });
后台内容:
- JsonArray tree = new JsonArray();
- JsonArray childs = new JsonArray();
-
- for(DisaRescueTaskView tView:tasks){
- JsonObject node = new JsonObject();
- node.addProperty("id", tView.getId());
- node.addProperty("text", tView.getName());
- node.addProperty("state", "closed");
- node.addProperty("icon", getTreeIconByRescueTaskMsg(tView));
- childs.add(node);
- }
-
- JsonObject root = new JsonObject();
- root.addProperty("id", "root");
- root.addProperty("text", "救援任务");
- root.addProperty("icon", "icon-ok");
- root.add("children", childs);
-
- tree.add(root);
- this.printOut(tree.toString());
注:当前节点的state属性设置成:closed,则展开该节点时,会异步展开这个节点下的所有子节点。
|