checkbox.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - 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. },
  21. data: {
  22. simpleData: {
  23. enable: true
  24. }
  25. }
  26. };
  27. var zNodes =[
  28. { id:1, pId:0, name:"can check 1", open:true},
  29. { id:11, pId:1, name:"can check 1-1", open:true},
  30. { id:111, pId:11, name:"can check 1-1-1"},
  31. { id:112, pId:11, name:"can check 1-1-2"},
  32. { id:12, pId:1, name:"can check 1-2", open:true},
  33. { id:121, pId:12, name:"can check 1-2-1"},
  34. { id:122, pId:12, name:"can check 1-2-2"},
  35. { id:2, pId:0, name:"can check 2", checked:true, open:true},
  36. { id:21, pId:2, name:"can check 2-1"},
  37. { id:22, pId:2, name:"can check 2-2", open:true},
  38. { id:221, pId:22, name:"can check 2-2-1", checked:true},
  39. { id:222, pId:22, name:"can check 2-2-2"},
  40. { id:23, pId:2, name:"can check 2-3"}
  41. ];
  42. var code;
  43. function setCheck() {
  44. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  45. py = $("#py").attr("checked")? "p":"",
  46. sy = $("#sy").attr("checked")? "s":"",
  47. pn = $("#pn").attr("checked")? "p":"",
  48. sn = $("#sn").attr("checked")? "s":"",
  49. type = { "Y":py + sy, "N":pn + sn};
  50. zTree.setting.check.chkboxType = type;
  51. showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
  52. }
  53. function showCode(str) {
  54. if (!code) code = $("#code");
  55. code.empty();
  56. code.append("<li>"+str+"</li>");
  57. }
  58. $(document).ready(function(){
  59. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  60. setCheck();
  61. $("#py").bind("change", setCheck);
  62. $("#sy").bind("change", setCheck);
  63. $("#pn").bind("change", setCheck);
  64. $("#sn").bind("change", setCheck);
  65. });
  66. //-->
  67. </SCRIPT>
  68. </HEAD>
  69. <BODY>
  70. <h1>Checkbox Operation</h1>
  71. <h6>[ File Path: excheck/checkbox.html ]</h6>
  72. <div class="content_wrap">
  73. <div class="zTreeDemoBackground left">
  74. <ul id="treeDemo" class="ztree"></ul>
  75. </div>
  76. <div class="right">
  77. <ul class="info">
  78. <li class="title"><h2>1, Explanation of setting</h2>
  79. <ul class="list">
  80. <li class="highlight_red">Must set setting.check attributes, see the API documentation for more related contents.</li>
  81. <li><p>Linkage relationship between parent and child nodes:<br/>
  82. check: <input type="checkbox" id="py" class="checkbox first" checked /><span>affect the parent</span>
  83. <input type="checkbox" id="sy" class="checkbox first" checked /><span>affect the child</span><br/>
  84. uncheck: <input type="checkbox" id="pn" class="checkbox first" checked /><span>affect the parent</span>
  85. <input type="checkbox" id="sn" class="checkbox first" checked /><span>affect the child</span><br/>
  86. <ul id="code" class="log" style="height:20px;"></ul></p>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="title"><h2>2, Explanation of treeNode</h2>
  91. <ul class="list">
  92. <li class="highlight_red">1), If you need to initialize the node is checked, please set treeNode.checked attribute. See the API documentation for more related contents.</li>
  93. <li class="highlight_red">2), If you need to initialize the node's checkbox is disabled, please set treeNode.chkDisabled attribute. See the API documentation for more related contents and 'chkDisabled Demo'.</li>
  94. <li class="highlight_red">3), If you need to initialize the node don't show checkbox, please set treeNode.nocheck attribute. See the API documentation for more related contents and 'nocheck Demo'.</li>
  95. <li class="highlight_red">4), If you need to change 'checked' to other attribute, please set setting.data.key.checked attribute. See the API documentation for more related contents.</li>
  96. <li>5), By the way, please see the API documentation for 'treeNode.checkedOld / getCheckStatus / check_Child_State / check_Focus'.</li>
  97. </ul>
  98. </li>
  99. </ul>
  100. </div>
  101. </div>
  102. </BODY>
  103. </HTML>