您好,欢迎访问一九零五行业门户网

jquery中EasyUI实现同步树_jquery

在js中,将显示树的url地址写成control的地址即可.
control:
复制代码 代码如下:
@requestmapping(value = /tree)
 public void tree(httpservletrequest request, httpservletresponse response) throws ioexception {
  this.writejson(response, bookservice.gettree());
 }
dao:
复制代码 代码如下:
/**
  * 获取树
  */
 @override
 public list gettree(){
  try {
   list trees = new arraylist();
   list root = this.search(0);
   if(root != null && root.size() > 0){
    for(tbooktype tb : root){
     tree rootnode = this.getnode(tb);
     rootnode.setstate(open);
     trees.add(rootnode);
    }
   }
   return trees;
  } catch (exception e) {
   e.printstacktrace();
   return null;
  }
 }
 /**
  * 递归
  */
 private tree getnode(tbooktype node){
  if(node == null){
   return null;
  }
  try {
   tree treenode = new tree();
   treenode.setid(string.valueof(node.getid()));
   treenode.settext(node.getname());
   treenode.setpid(string.valueof(node.getpid()));
   list children = this.search(node.getid());
   if(children != null && children.size() > 0){
    treenode.setstate(closed);
    for(tbooktype child : children){
     tree childnode = this.getnode(child);
     if(childnode != null){
      treenode.getchildren().add(childnode);//递归
     }
    }
   }
   return treenode;
  } catch (exception e) {
   throw new businessexception(获取数据出错!, e);
  }
 }
以上就是使用easyui实现同步树的全部核心代码了,希望大家能够喜欢。
其它类似信息

推荐信息