edit.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - edit</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. <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>
  12. <SCRIPT type="text/javascript">
  13. <!--
  14. var setting = {
  15. edit: {
  16. enable: true
  17. },
  18. data: {
  19. simpleData: {
  20. enable: true
  21. }
  22. },
  23. callback: {
  24. beforeDrag: beforeDrag
  25. }
  26. };
  27. var zNodes =[
  28. { id:1, pId:0, name:"父节点 1", open:true},
  29. { id:11, pId:1, name:"叶子节点 1-1"},
  30. { id:12, pId:1, name:"叶子节点 1-2"},
  31. { id:13, pId:1, name:"叶子节点 1-3"},
  32. { id:2, pId:0, name:"父节点 2", open:true},
  33. { id:21, pId:2, name:"叶子节点 2-1"},
  34. { id:22, pId:2, name:"叶子节点 2-2"},
  35. { id:23, pId:2, name:"叶子节点 2-3"},
  36. { id:3, pId:0, name:"父节点 3", open:true},
  37. { id:31, pId:3, name:"叶子节点 3-1"},
  38. { id:32, pId:3, name:"叶子节点 3-2"},
  39. { id:33, pId:3, name:"叶子节点 3-3"}
  40. ];
  41. function beforeDrag(treeId, treeNodes) {
  42. return false;
  43. }
  44. function setEdit() {
  45. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  46. remove = $("#remove").attr("checked"),
  47. rename = $("#rename").attr("checked"),
  48. removeTitle = $.trim($("#removeTitle").get(0).value),
  49. renameTitle = $.trim($("#renameTitle").get(0).value);
  50. zTree.setting.edit.showRemoveBtn = remove;
  51. zTree.setting.edit.showRenameBtn = rename;
  52. zTree.setting.edit.removeTitle = removeTitle;
  53. zTree.setting.edit.renameTitle = renameTitle;
  54. showCode(['setting.edit.showRemoveBtn = ' + remove, 'setting.edit.showRenameBtn = ' + rename,
  55. 'setting.edit.removeTitle = "' + removeTitle +'"', 'setting.edit.renameTitle = "' + renameTitle + '"']);
  56. }
  57. function showCode(str) {
  58. var code = $("#code");
  59. code.empty();
  60. for (var i=0, l=str.length; i<l; i++) {
  61. code.append("<li>"+str[i]+"</li>");
  62. }
  63. }
  64. $(document).ready(function(){
  65. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  66. setEdit();
  67. $("#remove").bind("change", setEdit);
  68. $("#rename").bind("change", setEdit);
  69. $("#removeTitle").bind("propertychange", setEdit)
  70. .bind("input", setEdit);
  71. $("#renameTitle").bind("propertychange", setEdit)
  72. .bind("input", setEdit);
  73. });
  74. //-->
  75. </SCRIPT>
  76. </HEAD>
  77. <BODY>
  78. <h1>基本 增 / 删 / 改 节点</h1>
  79. <h6>[ 文件路径: exedit/edit.html ]</h6>
  80. <div class="content_wrap">
  81. <div class="zTreeDemoBackground left">
  82. <ul id="treeDemo" class="ztree"></ul>
  83. </div>
  84. <div class="right">
  85. <ul class="info">
  86. <li class="title"><h2>1、setting 配置信息说明</h2>
  87. <ul class="list">
  88. <li>此 Demo 仅从功能上演示编辑节点的基本方法和配置参数</li>
  89. <li class="highlight_red">1)、使用 编辑功能,必须设置 setting.edit 中的各个属性,详细请参见 API 文档中的相关内容</li>
  90. <li class="highlight_red">2)、使用 编辑功能的事件回调函数,必须设置 setting.callback.beforeRemove / onRemove / beforeRename / onRename 等属性,详细请参见 API 文档中的相关内容</li>
  91. <li class="highlight_red">3)、zTree 不提供默认的增加按钮,如需实现请利用自定义控件的方法 addHoverDom / removeHoverDom ,详细请参见 API 文档中的相关内容;另外也可以参考 "高级 增 / 删 / 改 节点" 的 Demo</li>
  92. <li><p>基本编辑按钮设置:<br/>
  93. <input type="checkbox" id="remove" class="checkbox first" checked /><span>显示删除按钮</span>
  94. <input type="checkbox" id="rename" class="checkbox " checked /><span>显示编辑按钮</span><br/>
  95. remove 按钮的 title: <input type="text" id="removeTitle" value="remove" /><br/>
  96. rename 按钮的 title: <input type="text" id="renameTitle" value="rename" />
  97. <ul id="code" class="log" style="height:85px;"></ul></p>
  98. </li>
  99. </ul>
  100. </li>
  101. <li class="title"><h2>2、treeNode 节点数据说明</h2>
  102. <ul class="list">
  103. <li>对 节点数据 没有特殊要求,用户可以根据自己的需求添加自定义属性</li>
  104. </ul>
  105. </li>
  106. </ul>
  107. </div>
  108. </div>
  109. </BODY>
  110. </HTML>