checkbox_chkDisabled.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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:"随意勾选 1", open:true},
  29. { id:11, pId:1, name:"随意勾选 1-1", open:true},
  30. { id:111, pId:11, name:"disabled 1-1-1", chkDisabled:true},
  31. { id:112, pId:11, name:"随意勾选 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:"随意勾选 2", checked:true, open:true},
  36. { id:21, pId:2, name:"随意勾选 2-1"},
  37. { id:22, pId:2, name:"随意勾选 2-2", open:true},
  38. { id:221, pId:22, name:"随意勾选 2-2-1", checked:true},
  39. { id:222, pId:22, name:"随意勾选 2-2-2"},
  40. { id:23, pId:2, name:"随意勾选 2-3"}
  41. ];
  42. function disabledNode(e) {
  43. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  44. disabled = e.data.disabled,
  45. nodes = zTree.getSelectedNodes(),
  46. inheritParent = false, inheritChildren = false;
  47. if (nodes.length == 0) {
  48. alert("请先选择一个节点");
  49. }
  50. if (disabled) {
  51. inheritParent = $("#py").attr("checked");
  52. inheritChildren = $("#sy").attr("checked");
  53. } else {
  54. inheritParent = $("#pn").attr("checked");
  55. inheritChildren = $("#sn").attr("checked");
  56. }
  57. for (var i=0, l=nodes.length; i<l; i++) {
  58. zTree.setChkDisabled(nodes[i], disabled, inheritParent, inheritChildren);
  59. }
  60. }
  61. $(document).ready(function(){
  62. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  63. $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
  64. $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
  65. });
  66. //-->
  67. </SCRIPT>
  68. </HEAD>
  69. <BODY>
  70. <h1>Checkbox chkDisabled 演示</h1>
  71. <h6>[ 文件路径: excheck/checkbox_chkDisabled.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、setChkDisabled 方法操作说明</h2>
  79. <ul class="list">
  80. <li>setChkDisabled 方法可以设置节点 checkbox / radio 禁用 或 取消禁用,详细请参见 API 文档中的相关内容</li>
  81. <li><p>试试看:<br/>
  82. 禁用时:<input type="checkbox" id="py" class="checkbox first"/><span>关联父</span>
  83. <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
  84. 取消禁用时:<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
  85. <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
  86. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="disabledTrue" href="#" title="set checkbox to be disabled." onclick="return false;">禁用</a> ]
  87. &nbsp;&nbsp;&nbsp;&nbsp;[ <a id="disabledFalse" href="#" title="set checkbox to be abled." onclick="return false;">取消禁用</a> ]
  88. </li>
  89. </ul>
  90. </li>
  91. <li class="title"><h2>2、setting 配置信息说明</h2>
  92. <ul class="list">
  93. <li>这个 Demo 只简单演示 chkDisabled 的使用方法,详细配置信息请参考 ‘Checkbox 勾选操作’</li>
  94. </ul>
  95. </li>
  96. <li class="title"><h2>3、treeNode 节点数据说明</h2>
  97. <ul class="list">
  98. <li class="highlight_red">1)、如果某节点禁用 checkbox,请设置 treeNode.chkDisabled 属性,详细请参见 API 文档中的相关内容</li>
  99. <li>2)、其他请参考 ‘Checkbox 勾选操作’</li>
  100. </ul>
  101. </li>
  102. </ul>
  103. </div>
  104. </div>
  105. </BODY>
  106. </HTML>