oneclick.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - one click</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: false,
  17. showLine: false
  18. },
  19. data: {
  20. simpleData: {
  21. enable: true
  22. }
  23. },
  24. callback: {
  25. onClick: onClick
  26. }
  27. };
  28. var zNodes =[
  29. { id:1, pId:0, name:"根 Root", open:true},
  30. { id:11, pId:1, name:"父节点 1-1", open:true},
  31. { id:111, pId:11, name:"叶子节点 1-1-1"},
  32. { id:112, pId:11, name:"叶子节点 1-1-2"},
  33. { id:113, pId:11, name:"叶子节点 1-1-3"},
  34. { id:114, pId:11, name:"叶子节点 1-1-4"},
  35. { id:12, pId:1, name:"父节点 1-2", open:true},
  36. { id:121, pId:12, name:"叶子节点 1-2-1"},
  37. { id:122, pId:12, name:"叶子节点 1-2-2"},
  38. { id:123, pId:12, name:"叶子节点 1-2-3"},
  39. { id:124, pId:12, name:"叶子节点 1-2-4"},
  40. { id:13, pId:1, name:"父节点 1-3", open:true},
  41. { id:131, pId:13, name:"叶子节点 1-3-1"},
  42. { id:132, pId:13, name:"叶子节点 1-3-2"},
  43. { id:133, pId:13, name:"叶子节点 1-3-3"},
  44. { id:134, pId:13, name:"叶子节点 1-3-4"}
  45. ];
  46. function onClick(e,treeId, treeNode) {
  47. var zTree = $.fn.zTree.getZTreeObj("treeDemo");
  48. zTree.expandNode(treeNode);
  49. }
  50. $(document).ready(function(){
  51. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  52. });
  53. //-->
  54. </SCRIPT>
  55. <style type="text/css">
  56. .ztree li button.switch {visibility:hidden; width:1px;}
  57. .ztree li button.switch.roots_docu {visibility:visible; width:16px;}
  58. .ztree li button.switch.center_docu {visibility:visible; width:16px;}
  59. .ztree li button.switch.bottom_docu {visibility:visible; width:16px;}
  60. </style>
  61. </HEAD>
  62. <BODY>
  63. <h1>单击展开/折叠节点</h1>
  64. <h6>[ 文件路径: super/oneclick.html ]</h6>
  65. <div class="content_wrap">
  66. <div class="zTreeDemoBackground left">
  67. <ul id="treeDemo" class="ztree"></ul>
  68. </div>
  69. <div class="right">
  70. <ul class="info">
  71. <li class="title"><h2>实现方法说明</h2>
  72. <ul class="list">
  73. <li>zTree 默认不提供单击展开节点的功能,但可以利用 onClick 事件回调函数轻松实现此功能</li>
  74. <li class="highlight_red">为了避免与双击功能冲突,建议关闭双击展开节点的功能,请设置 setting.view.dblClickExpand = false </li>
  75. <li class="highlight_red">可以将所有的 +/- 开关隐藏,请查看本页面源码,查看 css 设置 </li>
  76. <li class="highlight_red">由于 +/- 开关与 节点连接线是配套的,所以如果不显示 +/- 开关的话,那么请设置 setting.view.showLine = false 隐藏连接线 </li>
  77. </ul>
  78. </li>
  79. </ul>
  80. </div>
  81. </div>
  82. </BODY>
  83. </HTML>