oneroot.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - one root</TITLE>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  6. <link rel="stylesheet" href="../../../css/demo.css" type="text/css">
  7. <link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
  8. <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
  9. <script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
  10. <!-- <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
  11. <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>-->
  12. <SCRIPT type="text/javascript">
  13. <!--
  14. var setting = {
  15. view: {
  16. dblClickExpand: dblClickExpand
  17. },
  18. data: {
  19. simpleData: {
  20. enable: true
  21. }
  22. }
  23. };
  24. var zNodes =[
  25. { id:1, pId:0, name:"根 Root", open:true},
  26. { id:11, pId:1, name:"父节点 1-1", open:true},
  27. { id:111, pId:11, name:"叶子节点 1-1-1"},
  28. { id:112, pId:11, name:"叶子节点 1-1-2"},
  29. { id:113, pId:11, name:"叶子节点 1-1-3"},
  30. { id:114, pId:11, name:"叶子节点 1-1-4"},
  31. { id:12, pId:1, name:"父节点 1-2", open:true},
  32. { id:121, pId:12, name:"叶子节点 1-2-1"},
  33. { id:122, pId:12, name:"叶子节点 1-2-2"},
  34. { id:123, pId:12, name:"叶子节点 1-2-3"},
  35. { id:124, pId:12, name:"叶子节点 1-2-4"},
  36. { id:13, pId:1, name:"父节点 1-3", open:true},
  37. { id:131, pId:13, name:"叶子节点 1-3-1"},
  38. { id:132, pId:13, name:"叶子节点 1-3-2"},
  39. { id:133, pId:13, name:"叶子节点 1-3-3"},
  40. { id:134, pId:13, name:"叶子节点 1-3-4"}
  41. ];
  42. function dblClickExpand(treeId, treeNode) {
  43. return treeNode.level > 0;
  44. }
  45. $(document).ready(function(){
  46. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  47. });
  48. //-->
  49. </SCRIPT>
  50. <style type="text/css">
  51. .ztree li span.button.switch.level0 {visibility:hidden; width:1px;}
  52. .ztree li ul.level0 {padding:0; background:none;}
  53. </style>
  54. </HEAD>
  55. <BODY>
  56. <h1>冻结根节点</h1>
  57. <h6>[ 文件路径: super/oneroot.html ]</h6>
  58. <div class="content_wrap">
  59. <div class="zTreeDemoBackground left">
  60. <ul id="treeDemo" class="ztree"></ul>
  61. </div>
  62. <div class="right">
  63. <ul class="info">
  64. <li class="title"><h2>实现方法说明</h2>
  65. <ul class="list">
  66. <li>对于这种只有一个根节点,且不显示 +/- 开关的需求,需要利用 css、setting 配合使用</li>
  67. <li class="highlight_red">zTree v3.x 可以针对指定的 level,进行样式设定,请查看本页面源码,查看 css 设置</li>
  68. <li class="highlight_red">设置 setting.view.dblClickExpand 指向 Function,可以只针对根节点关闭双击展开的操作</li>
  69. </ul>
  70. </li>
  71. </ul>
  72. </div>
  73. </div>
  74. </BODY>
  75. </HTML>