EasyUI combotree 使用递归动态填数据
2016-09-10 19:47
162 查看
public JSONArray getDepTree()throws Exception{ List<IntroWebCat> deps=Dao.GetParentIdTree(); JSONArray array=new JSONArray(); JSONObject o= new JSONObject(); o.put("id",0); o.put("text","无"); array.add(o); for(IntroWebCat d :deps){ if(d.getParentId()==null){ JSONObject temp=new JSONObject(); temp.put("id",d.getId()); temp.put("text",d.getCatName()); temp.put("state","open"); putTreeChild(temp, deps, d.getId()); array.add(temp); } } return array; } private void putTreeChild(JSONObject obj,List<IntroWebCat> list,Integer parId){ JSONArray array=new JSONArray(); for(IntroWebCat d :list){ if(parId.equals(d.getParentId()) ){ JSONObject temp=new JSONObject(); temp.put("id",d.getId()); temp.put("text",d.getCatName()); temp.put("state","open"); putTreeChild(temp, list, d.getId()); array.add(temp); } } if(!array.isEmpty()) obj.put("children",array); }
相关文章推荐
- 一种使用递归从数据库读取数据来动态建立菜单的方法
- 使用递归从数据库读取数据来动态建立菜单
- Struts menu的使用(动态数据)
- 动态库中使用STL数据类型
- 使用Ajax动态加载数据
- 使用 JSP 技术和 JDBC 技术访问基于 Web 的动态数据
- 使用 JSP 技术和 JDBC 技术访问基于 Web 的动态数据
- 使用Using System.Data.OleDb; 连接数据库,又一种动态绑定GridView显示数据。
- SolpartMenu的使用:(二)、在ASP.NET页面中使用SolpartMenu控件之动态的加载数据库中的数据来生成菜单
- 使用该JavaBean可以将数据在JSP页面中以表格的形式显示出来,并具有动态排序、动态生成查询、自动分页功能
- 使用oracle 9i 里的层级查询(Hierarchical Queries)实现树状表结构的递归数据查询
- 使用js动态添加文本框 并在后台取文本框数据
- vb.net使用水晶报表显示动态Dataset的数据
- 数据层使用Server对象;动态生成控件多文件上传
- 从XML文件读取数据动态设置Tree控件使用
- JSP培训(7)——使用JDBC完成动态验证、采用MVC完成数据查询
- 使用函数递归实现基于php和MySQL的动态树型菜单
- 使用函数递归实现基于PHP和MySQL的动态树型菜单[转]
- [自我总结]如何使用VS2005中的OLEDB的JET SQL驱动来动态创建数据表!
- 使用Ajax动态加载数据