jquery中EasyUI实现同步树
在JS中,将显示树的url地址写成control的地址即可.
control:
@RequestMapping(value="/tree")
publicvoidtree(HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException{
this.writeJson(response,bookService.getTree());
}
dao:
/**
*获取树
*/
@Override
publicList<Tree>getTree(){
try{
List<Tree>trees=newArrayList<Tree>();
List<TBookType>root=this.search(0);
if(root!=null&&root.size()>0){
for(TBookTypetb:root){
Treerootnode=this.getNode(tb);
rootnode.setState("open");
trees.add(rootnode);
}
}
returntrees;
}catch(Exceptione){
e.printStackTrace();
returnnull;
}
}
/**
*递归
*/
privateTreegetNode(TBookTypenode){
if(node==null){
returnnull;
}
try{
Treetreenode=newTree();
treenode.setId(String.valueOf(node.getId()));
treenode.setText(node.getName());
treenode.setPid(String.valueOf(node.getPid()));
List<TBookType>children=this.search(node.getId());
if(children!=null&&children.size()>0){
treenode.setState("closed");
for(TBookTypechild:children){
Treechildnode=this.getNode(child);
if(childnode!=null){
treenode.getChildren().add(childnode);//递归
}
}
}
returntreenode;
}catch(Exceptione){
thrownewBusinessException("获取数据出错!",e);
}
}
以上就是使用EasyUI实现同步树的全部核心代码了,希望大家能够喜欢。
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短