checkbox_chkDisabled.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - Checkbox chkDisabled</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. check: {
  18. enable: true,
  19. chkDisabledInherit: 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:"disabled 1-1-1", chkDisabled:true},
  31. { id:112, pId:11, name:"can check 1-1-2"},
  32. { id:12, pId:1, name:"disabled 1-2", chkDisabled:true, checked:true, open:true},
  33. { id:121, pId:12, name:"disabled 1-2-1", checked:true},
  34. { id:122, pId:12, name:"disabled 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. function disabledNode(e) {
  43. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  44. disabled = e.data.disabled,
  45. nodes = zTree.getSelectedNodes();
  46. if (nodes.length == 0) {
  47. alert("Please select one node at first...");
  48. }
  49. if (disabled) {
  50. inheritParent = $("#py").attr("checked");
  51. inheritChildren = $("#sy").attr("checked");
  52. } else {
  53. inheritParent = $("#pn").attr("checked");
  54. inheritChildren = $("#sn").attr("checked");
  55. }
  56. for (var i=0, l=nodes.length; i<l; i++) {
  57. zTree.setChkDisabled(nodes[i], disabled, inheritParent, inheritChildren);
  58. }
  59. }
  60. $(document).ready(function(){
  61. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  62. $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
  63. $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
  64. });
  65. //-->
  66. </SCRIPT>
  67. </HEAD>
  68. <BODY>
  69. <h1>Checkbox chkDisabled Demo</h1>
  70. <h6>[ File Path: excheck/checkbox_chkDisabled.html ]</h6>
  71. <div class="content_wrap">
  72. <div class="zTreeDemoBackground left">
  73. <ul id="treeDemo" class="ztree"></ul>
  74. </div>
  75. <div class="right">
  76. <ul class="info">
  77. <li class="title"><h2>1, Explanation of 'setChkDisabled' method</h2>
  78. <ul class="list">
  79. <li>'setChkDisabled' method can set the node's checkbox / radio to be disabled or abled. See the API documentation for more related contents.</li>
  80. <li><p>Try:<br/>
  81. disabled: <input type="checkbox" id="py" class="checkbox first" /><span>affect the parent</span>
  82. <input type="checkbox" id="sy" class="checkbox first" checked /><span>affect the child</span><br/>
  83. unDisabled: <input type="checkbox" id="pn" class="checkbox first" checked /><span>affect the parent</span>
  84. <input type="checkbox" id="sn" class="checkbox first" checked /><span>affect the child</span><br/>
  85. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="disabledTrue" href="#" title="set checkbox to be disabled." onclick="return false;">be disabled</a> ]
  86. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="disabledFalse" href="#" title="set checkbox to be abled." onclick="return false;">be abled</a> ]</p>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="title"><h2>2, Explanation of setting</h2>
  91. <ul class="list">
  92. <li>This Demo only shows how use the ‘chkDisabled’ attribute, detailed configuration information, please refer to 'Checkbox Operation'</li>
  93. </ul>
  94. </li>
  95. <li class="title"><h2>3, Explanation of treeNode</h2>
  96. <ul class="list">
  97. <li class="highlight_red">1), If you need to initialize the node's checkbox is disabled, please set treeNode.chkDisabled attribute. See the API documentation for more related contents.</li>
  98. <li>2), By the way, please see the 'Checkbox Operation' Demo.</li>
  99. </ul>
  100. </li>
  101. </ul>
  102. </div>
  103. </div>
  104. </BODY>
  105. </HTML>