checkbox_halfCheck.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - Checkbox halfCheck</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. <!--
  12. <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>
  13. -->
  14. <SCRIPT type="text/javascript">
  15. <!--
  16. var setting = {
  17. async: {
  18. enable: true,
  19. url:"../asyncData/getNodes.php",
  20. autoParam:["id", "name=n", "level=lv"],
  21. otherParam:{"chk":"chk"},
  22. dataFilter: dataFilter
  23. },
  24. check: {
  25. enable: true,
  26. autoCheckTrigger: true
  27. },
  28. data: {
  29. simpleData: {
  30. enable: true
  31. }
  32. },
  33. callback: {
  34. onCheck: onCheck,
  35. onAsyncSuccess: onAsyncSuccess
  36. }
  37. };
  38. function dataFilter(treeId, parentNode, childNodes) {
  39. if (parentNode.checkedEx === true) {
  40. for(var i=0, l=childNodes.length; i<l; i++) {
  41. childNodes[i].checked = parentNode.checked;
  42. childNodes[i].halfCheck = false;
  43. childNodes[i].checkedEx = true;
  44. }
  45. }
  46. return childNodes;
  47. }
  48. function onCheck(event, treeId, treeNode) {
  49. cancelHalf(treeNode)
  50. treeNode.checkedEx = true;
  51. }
  52. function onAsyncSuccess(event, treeId, treeNode, msg) {
  53. cancelHalf(treeNode);
  54. }
  55. function cancelHalf(treeNode) {
  56. if (treeNode.checkedEx) return;
  57. var zTree = $.fn.zTree.getZTreeObj("treeDemo");
  58. treeNode.halfCheck = false;
  59. zTree.updateNode(treeNode);
  60. }
  61. var zNodes =[
  62. { id:1, pId:0, name:"half 1", halfCheck:true, isParent:true},
  63. { id:2, pId:0, name:"half 2", halfCheck:true, checked:true, isParent:true},
  64. { id:3, pId:0, name:"no half 3", checked:true, isParent:true}
  65. ];
  66. $(document).ready(function(){
  67. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  68. });
  69. //-->
  70. </SCRIPT>
  71. </HEAD>
  72. <BODY>
  73. <h1>Checkbox halfCheck Demo</h1>
  74. <h6>[ File Path: excheck/checkbox_halfCheck.html ]</h6>
  75. <div class="content_wrap">
  76. <div class="zTreeDemoBackground left">
  77. <ul id="treeDemo" class="ztree"></ul>
  78. </div>
  79. <div class="right">
  80. <ul class="info">
  81. <li class="title"><h2>1, Explanation of Demo</h2>
  82. <ul class="list">
  83. <li>This demo implements the check operation of the dynamic tree</li>
  84. <li class="highlight_red">1). After loaded child nodes, the parent node's 'halfCheck' attribute will be invalid immediately.</li>
  85. <li class="highlight_red">2). If you check the parent node, so will effect the child nodes's check status.</li>
  86. <li class="highlight_red">3). If you check the parent node, it's child node's 'halfCheck' attribute will be invalid.</li>
  87. </ul>
  88. </li>
  89. <li class="title"><h2>2, Explanation of setting</h2>
  90. <ul class="list">
  91. <li>Half-checked functional don't need to configure any parameter. But it is accessibility, can not used alone. So please configure the parameters which you need.</li>
  92. </ul>
  93. </li>
  94. <li class="title"><h2>3, Explanation of treeNode</h2>
  95. <ul class="list">
  96. <li class="highlight_red">1), Please set treeNode.halfCheck attribute, before zTree initialize. See the API documentation for more related contents.</li>
  97. <li>2), By the way, please see the 'Checkbox Operation' Demo.</li>
  98. </ul>
  99. </li>
  100. </ul>
  101. </div>
  102. </div>
  103. </BODY>
  104. </HTML>