radio.html 3.6 KB

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