checkbox_nocheck.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - no checkbox</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.min.js"></script>
  9. <!-- <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>-->
  10. <script type="text/javascript" src="../../../js/jquery.ztree.core.js"></script>
  11. <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
  12. <!--
  13. <script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>
  14. -->
  15. <SCRIPT type="text/javascript">
  16. <!--
  17. var setting = {
  18. check: {
  19. enable: true,
  20. nocheckInherit: true
  21. },
  22. data: {
  23. simpleData: {
  24. enable: true
  25. }
  26. }
  27. };
  28. var zNodes =[
  29. { id:1, pId:0, name:"can check 1", open:true},
  30. { id:11, pId:1, name:"can check 1-1", open:true},
  31. { id:111, pId:11, name:"no checkbox 1-1-1", nocheck:true},
  32. { id:112, pId:11, name:"can check 1-1-2"},
  33. { id:12, pId:1, name:"no checkbox 1-2", nocheck:true, open:true},
  34. { id:121, pId:12, name:"no checkbox 1-2-1"},
  35. { id:122, pId:12, name:"no checkbox 1-2-2"},
  36. { id:2, pId:0, name:"can check 2", checked:true, open:true},
  37. { id:21, pId:2, name:"can check 2-1"},
  38. { id:22, pId:2, name:"can check 2-2", open:true},
  39. { id:221, pId:22, name:"can check 2-2-1", checked:true},
  40. { id:222, pId:22, name:"can check 2-2-2"},
  41. { id:23, pId:2, name:"can check 2-3"}
  42. ];
  43. function nocheckNode(e) {
  44. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  45. nocheck = e.data.nocheck,
  46. nodes = zTree.getSelectedNodes();
  47. if (nodes.length == 0) {
  48. alert("Please select one node at first...");
  49. }
  50. for (var i=0, l=nodes.length; i<l; i++) {
  51. nodes[i].nocheck = nocheck;
  52. zTree.updateNode(nodes[i]);
  53. }
  54. }
  55. $(document).ready(function(){
  56. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  57. $("#nocheckTrue").bind("click", {nocheck: true}, nocheckNode);
  58. $("#nocheckFalse").bind("click", {nocheck: false}, nocheckNode);
  59. });
  60. //-->
  61. </SCRIPT>
  62. </HEAD>
  63. <BODY>
  64. <h1>Checkbox nocheck Demo</h1>
  65. <h6>[ File Path: excheck/checkbox_nocheck.html ]</h6>
  66. <div class="content_wrap">
  67. <div class="zTreeDemoBackground left">
  68. <ul id="treeDemo" class="ztree"></ul>
  69. </div>
  70. <div class="right">
  71. <ul class="info">
  72. <li class="title"><h2>1, Explanation of setting</h2>
  73. <ul class="list">
  74. <li>This Demo only shows how use the ‘nocheck’ attribute, detailed configuration information, please refer to 'Checkbox Operation'</li>
  75. <li class="highlight_red">setting.check.nocheckInherit can set the child nodes to automatically inherit the parent node's 'nocheck' attribute. See the API documentation for more related contents.</li>
  76. <li><p>Try:<br/>
  77. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="nocheckTrue" href="#" title="set checkbox to be hidden." onclick="return false;">hide checkbox</a> ]
  78. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="nocheckFalse" href="#" title="set checkbox to be show." onclick="return false;">show checkbox</a> ]
  79. </li>
  80. </ul>
  81. </li>
  82. <li class="title"><h2>2, Explanation of treeNode</h2>
  83. <ul class="list">
  84. <li class="highlight_red">1), If you need to initialize the node don't show checkbox, please set treeNode.nocheck attribute. See the API documentation for more related contents.</li>
  85. <li>2), By the way, please see the 'Checkbox Operation' Demo.</li>
  86. </ul>
  87. </li>
  88. </ul>
  89. </div>
  90. </div>
  91. </BODY>
  92. </HTML>