jquery中EasyUI实现异步树
2015-03-01 00:00
555 查看
前台使用EasyUI实现 . EasyUI向后台传递一个id参数 .
第一次加载 , 向后台传递的id为null .
之后每次将树节点展开 , 会向后台传递一个当前节点的 id .
Control层 :
Service层 :
Dao层 :
以上所述就是本文关于EasyUI实现异步树的全部代码了,希望对大家能有所帮助
第一次加载 , 向后台传递的id为null .
之后每次将树节点展开 , 会向后台传递一个当前节点的 id .
Control层 :
/** * tree */ @RequestMapping(value = "/tree.do") public void mytree(HttpServletResponse response, String id) { this.writeJson(response, bookService.getChildrenTree(id)); }
Service层 :
@Transactional @Override public List<Tree> getChildrenTree(String pid) { try { List<Tree> result = new ArrayList<Tree>(); //获得儿子节点的列表 List<TBookType> childrenList = this.getChildrenType(pid); if (childrenList != null && childrenList.size() > 0) { for (TBookType child : childrenList) { // 获取孙子的个数 long count = bookDao.getChildrenCount(String.valueOf(child.getId())); Tree node = new Tree(); node.setId(String.valueOf(child.getId())); node.setPid(String.valueOf(child.getPid())); node.setText(child.getName()); node.setChildren(null); node.setState(count > 0 ? "closed" : "open"); //将儿子列表childrenList数据逐个存到树当中 result.add(node); } } return result; } catch (Exception e) { throw new BusinessException("获取图书类型数据出现错误!", e); } }
Dao层 :
@Override public List<TBookType> getChildrenType(String pid) { //这个的pid就是当前展开节点的id , 通过父节点的 id 来获得子节点 StringBuilder sqlstr = new StringBuilder(); if (StringUtils.isBlank(pid)) sqlstr.append("select * from booktype bt where bt.pid=0"); else sqlstr.append("select * from booktype bt where bt.pid=" + pid ); return this.search2(TBookType.class, sqlstr.toString()); }
@Override public long getChildrenCount(String pid) { //这个的pid就是当前展开节点的id , 通过父节点的 id 来获得子节点的个数 StringBuilder sqlstr = new StringBuilder(); if (StringUtils.isBlank(pid)) sqlstr.append("select count(*) from booktype tb where tb.pid='0'"); else sqlstr.append("select count(*) from booktype tb where tb.pid='" + pid + "'"); return this.count(sqlstr.toString()); }
以上所述就是本文关于EasyUI实现异步树的全部代码了,希望对大家能有所帮助
相关文章推荐
- Jquery Ajax+EF+JqueryEasyUi实现的异步无刷新分页+MVC和EF的搭建
- jquery中EasyUI实现异步树
- Asp.net+Jquery实现用户信息异步验证
- Asp.net+Jquery实现用户信息异步验证
- 黄聪:Jquery+php+ajax实现表单异步提交,动态添加回复评论
- MVC+Jquery easyui实现无限级部门小示例
- easyUI布局篇使用jquery easy UI的panel和layout实现界面的自适用窗口
- 自学MVC(九):jquery里实现ajax无刷新发表评论,和异步获取评论,带loading-2009年05月22日
- jQuery-Easyui 1.2 实现多层菜单效果的代码
- JQuery实现异步刷新(原创)
- struts2 jquery 插件实现ajax异步请求(网上资料)
- jquery实现注册时异步检测用户名是否存在
- 利用jQuery 实现GridView异步排序、分页的代码
- Asp.net+Jquery实现用户信息异步验证
- jquery easyui Create Async Tree (异步加载目录树)
- 基于JQuery实现异步刷新的代码(转载)
- Asp.net和Jquery实现用户信息异步验证
- JQuery Easyui Tree的oncheck事件实现代码
- jquery异步循环获取功能实现代码
- easyui+Jquery加载异步树