checkbox.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-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. },
  20. data: {
  21. simpleData: {
  22. enable: true
  23. }
  24. }
  25. };
  26. var zNodes =[
  27. { id:1, pId:0, name:"随意勾选 1", open:true},
  28. { id:11, pId:1, name:"随意勾选 1-1", open:true},
  29. { id:111, pId:11, name:"随意勾选 1-1-1"},
  30. { id:112, pId:11, name:"随意勾选 1-1-2"},
  31. { id:12, pId:1, name:"随意勾选 1-2", open:true},
  32. { id:121, pId:12, name:"随意勾选 1-2-1"},
  33. { id:122, pId:12, name:"随意勾选 1-2-2"},
  34. { id:2, pId:0, name:"随意勾选 2", checked:true, open:true},
  35. { id:21, pId:2, name:"随意勾选 2-1"},
  36. { id:22, pId:2, name:"随意勾选 2-2", open:true},
  37. { id:221, pId:22, name:"随意勾选 2-2-1", checked:true},
  38. { id:222, pId:22, name:"随意勾选 2-2-2"},
  39. { id:23, pId:2, name:"随意勾选 2-3"}
  40. ];
  41. var code;
  42. function setCheck() {
  43. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  44. py = $("#py").attr("checked")? "p":"",
  45. sy = $("#sy").attr("checked")? "s":"",
  46. pn = $("#pn").attr("checked")? "p":"",
  47. sn = $("#sn").attr("checked")? "s":"",
  48. type = { "Y":py + sy, "N":pn + sn};
  49. zTree.setting.check.chkboxType = type;
  50. showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
  51. }
  52. function showCode(str) {
  53. if (!code) code = $("#code");
  54. code.empty();
  55. code.append("<li>"+str+"</li>");
  56. }
  57. $(document).ready(function(){
  58. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  59. setCheck();
  60. $("#py").bind("change", setCheck);
  61. $("#sy").bind("change", setCheck);
  62. $("#pn").bind("change", setCheck);
  63. $("#sn").bind("change", setCheck);
  64. });
  65. //-->
  66. </SCRIPT>
  67. </HEAD>
  68. <BODY>
  69. <h1>Checkbox 勾选操作</h1>
  70. <h6>[ 文件路径: excheck/checkbox.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、setting 配置信息说明</h2>
  78. <ul class="list">
  79. <li class="highlight_red">使用 checkbox,必须设置 setting.check 中的各个属性,详细请参见 API 文档中的相关内容</li>
  80. <li><p>父子关联关系:<br/>
  81. 被勾选时:<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
  82. <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
  83. 取消勾选时:<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
  84. <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
  85. <ul id="code" class="log" style="height:20px;"></ul></p>
  86. </li>
  87. </ul>
  88. </li>
  89. <li class="title"><h2>2、treeNode 节点数据说明</h2>
  90. <ul class="list">
  91. <li class="highlight_red">1)、如果需要初始化默认节点被勾选,请设置 treeNode.checked 属性,详细请参见 API 文档中的相关内容</li>
  92. <li class="highlight_red">2)、如果某节点禁用 checkbox,请设置 treeNode.chkDisabled 属性,详细请参见 API 文档中的相关内容 和 'chkDisabled 演示'</li>
  93. <li class="highlight_red">3)、如果某节点不显示 checkbox,请设置 treeNode.nocheck 属性,详细请参见 API 文档中的相关内容 和 'nocheck 演示'</li>
  94. <li class="highlight_red">4)、如果更换 checked 属性,请参考 API 文档中 setting.data.key.checked 的详细说明</li>
  95. <li>5)、其他请参考 API 文档中 treeNode.checkedOld / getCheckStatus / check_Child_State / check_Focus 的详细说明</li>
  96. </ul>
  97. </li>
  98. </ul>
  99. </div>
  100. </div>
  101. </BODY>
  102. </HTML>