f91366bed2d5d8058f8447fd370b4e760b9ade83.svn-base 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>树的拖放</title>
  6. <!--框架必需start-->
  7. <script type="text/javascript" src="../../libs/js/jquery.js"></script>
  8. <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
  9. <script type="text/javascript" src="../../libs/js/framework.js"></script>
  10. <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  11. <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
  12. <link rel="stylesheet" type="text/css" id="customSkin"/>
  13. <!--框架必需end-->
  14. <!-- ztree start -->
  15. <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
  16. <link href="../../libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
  17. <!-- ztree end -->
  18. </head>
  19. <body>
  20. <div class="box1" style="width: 800px;"><div class="box_topcenter"><div class="box_topleft"><div class="box_topright"></div></div></div><div class="box_middlecenter"><div class="box_middleleft"><div class="box_middleright"><div class="boxContent" style="overflow: visible;">
  21. <fieldset>
  22. <legend>1、基本使用</legend>
  23. <div>
  24. <ul id="tree-1" class="ztree"></ul>
  25. </div>
  26. </fieldset>
  27. <div class="height_15"></div>
  28. </div></div></div></div><div class="box_bottomcenter"><div class="box_bottomleft"><div class="box_bottomright"></div></div></div></div>
  29. <script type="text/javascript">
  30. var setting1 = {
  31. edit: {
  32. enable: true,
  33. showRemoveBtn: false,
  34. showRenameBtn: false
  35. },
  36. callback:{
  37. beforeDrag: beforeDrag1,
  38. beforeDrop: beforeDrop1
  39. }
  40. };
  41. var zNodes1 = [
  42. { id:1, parentId:0, name:"随意拖拽 1", open:true},
  43. { id:11, parentId:1, name:"随意拖拽 1-1"},
  44. { id:12, parentId:1, name:"随意拖拽 1-2", open:true},
  45. { id:121, parentId:12, name:"随意拖拽 1-2-1"},
  46. { id:122, parentId:12, name:"随意拖拽 1-2-2"},
  47. { id:123, parentId:12, name:"随意拖拽 1-2-3"},
  48. { id:13, parentId:1, name:"禁止拖拽 1-3", open:true, drag:false},
  49. { id:131, parentId:13, name:"禁止拖拽 1-3-1", drag:false},
  50. { id:132, parentId:13, name:"禁止拖拽 1-3-2", drag:false},
  51. { id:133, parentId:13, name:"随意拖拽 1-3-3"},
  52. { id:2, parentId:0, name:"随意拖拽 2", open:true},
  53. { id:21, parentId:2, name:"随意拖拽 2-1"},
  54. { id:22, parentId:2, name:"禁止拖拽到我身上 2-2", open:true, drop:false},
  55. { id:221, parentId:22, name:"随意拖拽 2-2-1"},
  56. { id:222, parentId:22, name:"随意拖拽 2-2-2"},
  57. { id:223, parentId:22, name:"随意拖拽 2-2-3"},
  58. { id:23, parentId:2, name:"随意拖拽 2-3"}
  59. ];
  60. function initComplete(){
  61. $.fn.zTree.init($("#tree-1"), setting1, zNodes1);
  62. }
  63. //实现树的拖放,这个方法是必须的
  64. function beforeDrag1(treeId, treeNodes) {
  65. for (var i = 0, l = treeNodes.length; i < l; i++) {
  66. if(treeNodes[i].drag === false) {
  67. return false;
  68. }
  69. }
  70. return true;
  71. }
  72. //实现树的拖放,这个方法是必须的
  73. function beforeDrop1(treeId, treeNodes, targetNode, moveType) {
  74. return targetNode ? targetNode.drop !== false : true;
  75. }
  76. </script>
  77. </body>
  78. </html>