应用页面
<html> <head> <title>category tree</title> <link rel="StyleSheet" href="css/dtree.css" type="text/css" /> <script type="text/javascript" src="script/dtree.js"></script> </head> <body> <div class="dtree"> <p><input name="OpenAll" type="button" value="OpenAll" onclick="javascript: d.openAll();"/> | <input name="CloseAll" value="CloseAll" type="button" onclick="javascript: d.closeAll();"/></p> <script type="text/javascript"> d = new dTree(‘d‘); d.config.check=false; //没有复选框 d.config.useIcons =false; //有图片; d.add(0,-1,‘category tree‘); <% List<Category> list = CategoryManager.getCategories(); Iterator<Category> iter = list.iterator(); while(iter.hasNext()){ Category c = iter.next(); %> //编号,父节点编号,连接 d.add(<%=c.getId()%>,<%=c.getPid()%>,‘<%=c.getName()%>‘,‘categoryadd.jsp?pid=<%=c.getId()%>‘); <% } %> /* //自己的菜单编号,父节点编号,名称,链接,提示,显示位置 d.add(3,‘n‘,‘Node 1.1‘,‘#‘); d.add(‘n‘,0,‘Node 1‘); d.add(2,0,‘Node 2‘); d.add(4,0,‘Node 3‘,‘#‘); d.add(5,3,‘Node 1.1.1‘,‘#‘); d.add(6,5,‘Node 1.1.1.1‘,‘#‘); d.add(7,0,‘Node 4‘,"javascript:alert(‘aaaaaaaaaaa‘);"); d.add(8,‘n‘,‘Node 1.2‘,‘#‘); d.add(9,0,‘My Pictures‘,‘#‘,‘Pictures I\‘ve taken over the years‘,‘‘,‘‘,‘img/imgfolder.gif‘); d.add(10,9,‘The trip to Iceland‘,‘#‘,‘Pictures of Gullfoss and Geysir‘); d.add(11,9,‘Mom\‘s birthday‘,‘#‘); //d.add(12,0,‘Recycle Bin‘,‘#‘,‘‘,‘‘,‘img/trash.gif‘); d.add("c",4,‘node 4.1‘,"#"); */ document.write(d); </script> </div> </body> </html>
参考文章地址:http://zhouhaitao.iteye.com/blog/1130278
时间: 2024-10-08 13:04:04