Jquery dtree的使用

 Dtree目录树的总结

                  一:函数

                           1:页面中
                              tree.add(id,pid,name,url,title,target,icon,iconOpen,open);
                                  参数说明:
                                              id         :节点自身的id
                                              pid       :节点的父节点的id
                                              name    :节点显示在页面上的名称
                                              url        :节点的链接地址
                                              title      :鼠标放在节点上所出现的提示信息
                                              target   :节点链接所打开的目标frame(如框架目标mainFrame,_blank,_self 类)
                                              icon      :节点关闭时的显示图片的路径
                                              iconOpen:节点打开时的显示图片的路径
                                              open    :布尔型,节点是否打开(默认为false)
                                             注:open项:顶级节点一般采用true,即pid是-1的节点

                            2:dtree.js文件中
                                             约87-113行是一些默认图片的路径,注意要指对。


二:页面中的书写
          1:默认值的书写规则(从左至右,依次省略)
                          即 tree.add(id,pid,name,url);后面5个参数可以省略
          2:有间隔时的默认值(如存在第6个参数,但第5个参数想用默认值)
                         即 tree.add(id,pid,name,url,"",target);必须这样写
         3:样式表
           (1):可以将dtree.css中的样式附加到你的应用中的主css中,如a.css
           (2):也可以同时引用dtree.css与a.css两个文件,但前提条件是两个css文件中不能有重复的样式

静态代码,也可以循环遍历从数据库读取结点数据动态构件。至于接受的数据类型可以使xml或者json都行。

  1. <script type="text/javascript">  
  2. tree = new dTree('tree');  
  3. tree.add("1","-1","京津","","","","","",true);  
  4. tree.add("11","1","A","","","","","",true);  
  5.  tree.add("110","11","A-1","content.jsp?moduleName=XXX","","mainFrame");  
  6.  tree.add("111","11","A-2","javascript:void(0)","","链接在哪里显示");  
  7.  tree.add("112","11","A-3","javascript:void(0)","","mainFrame");  
  8.  tree.add("113","11","A-4","/.jsp","","mainFrame");  
  9.  tree.add("114","11","A-5","/.jsp","","mainFrame");  
  10.  tree.add("115","11","A-6","/.jsp","","mainFrame");  
  11.    
  12. tree.add("12","1","B","","","","","",true);  
  13.  tree.add("121","12","B-1","javascript:调用本页内的js函数","","mainFrame");  
  14.  tree.add("122","12","B-2");  
  15. tree.add("13","1","C","","","","","",true);  
  16.  tree.add("131","13","C-1","javascript:void(0)","","mainFrame");  
  17.  tree.add("132","13","C-2","javascript:void(0)","","mainFrame");  
  18.  tree.add("133","13","C-3","javascript:void(0)","","mainFrame");  
  19. tree.add("14","1","D","","","","","",true);  
  20.  tree.add("141","14","D-1","javascript:void(0)","","mainFrame");  
  21. document.write(tree);  
  22. </script>  

相关推荐