1) 在jsp页面中引入ligerui所需要的jar包(要根据要实现的不同的功能引入不同的jar包,如tree引入LigerTree的jar包,grid引入LigerGrid的jar包。。)
2) js代码:(ligertree有两种数据绑定的类型,(1):基于data, (2)基于url。 )
$("#tree1").ligerTree( { data:data });
或者: $(“#tree1”).ligerTree({ url: ‘tree.json’, ajaxType: ‘get’ });
//显示树 $("#treeDatas").ligerTree({ url : 'getAllDirs?' + $.param({ typeid : '1', parentid : '0' }), checkbox : false, slide : false, isleaf : false, // onBeforeExpand : onBeforeExpand, onSelect :onSelect , onClick : function(node) { if (node != null && node.data != null) { nodeid = node.data.id; //alert(nodeid); if (nodeid != -1 && node.data.typeid == -1) { gridManager.setOptions({ parms : [ { name : 'organid', value : nodeid } ] }); gridManager.loadData(true); } } } });
list = new UploadFileDaoImpl().findAllDirs();
String s = req.getParameter(“typeid”);
String s1 = req.getParameter(“parentid”);
int xx = Integer.parseInt(s1);
//System.out.println(s);
//System.out.println(s1);
JSONObject json = new JSONObject(); String treeJson = ""; int pid; NodeUtil nodeUtil = new NodeUtil(); JSONArray jsonArray = new JSONArray(); String jsonArray2 = null; for(int i=0;i
0) { for (Dir dir : list) { json.put("id", dir.getId()); json.put("text", dir.getDirName()); json.put("pid", dir.getPid()); json.put("children", "[]"); treeJson += json.toString() + ","; } } String string2 = "[{\"text\":\"upload\",\"id\":0,\"pid\":0,\"children\":"+string+"}]"; printWriter.print(string2); printWriter.flush(); printWriter.close(); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/221649.html原文链接:https://javaforall.net
