12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>树的拖放</title>
- <!--框架必需start-->
- <script type="text/javascript" src="../../libs/js/jquery.js"></script>
- <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
- <script type="text/javascript" src="../../libs/js/framework.js"></script>
- <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
- <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
- <link rel="stylesheet" type="text/css" id="customSkin"/>
- <!--框架必需end-->
- <!-- ztree start -->
- <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
- <link href="../../libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
- <!-- ztree end -->
- </head>
- <body>
- <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;">
-
- <fieldset>
- <legend>1、基本使用</legend>
- <div>
- <ul id="tree-1" class="ztree"></ul>
- </div>
- </fieldset>
- <div class="height_15"></div>
-
-
- </div></div></div></div><div class="box_bottomcenter"><div class="box_bottomleft"><div class="box_bottomright"></div></div></div></div>
-
- <script type="text/javascript">
-
- var setting1 = {
- edit: {
- enable: true,
- showRemoveBtn: false,
- showRenameBtn: false
- },
- callback:{
- beforeDrag: beforeDrag1,
- beforeDrop: beforeDrop1
- }
- };
-
-
- var zNodes1 = [
- { id:1, parentId:0, name:"随意拖拽 1", open:true},
- { id:11, parentId:1, name:"随意拖拽 1-1"},
- { id:12, parentId:1, name:"随意拖拽 1-2", open:true},
- { id:121, parentId:12, name:"随意拖拽 1-2-1"},
- { id:122, parentId:12, name:"随意拖拽 1-2-2"},
- { id:123, parentId:12, name:"随意拖拽 1-2-3"},
- { id:13, parentId:1, name:"禁止拖拽 1-3", open:true, drag:false},
- { id:131, parentId:13, name:"禁止拖拽 1-3-1", drag:false},
- { id:132, parentId:13, name:"禁止拖拽 1-3-2", drag:false},
- { id:133, parentId:13, name:"随意拖拽 1-3-3"},
- { id:2, parentId:0, name:"随意拖拽 2", open:true},
- { id:21, parentId:2, name:"随意拖拽 2-1"},
- { id:22, parentId:2, name:"禁止拖拽到我身上 2-2", open:true, drop:false},
- { id:221, parentId:22, name:"随意拖拽 2-2-1"},
- { id:222, parentId:22, name:"随意拖拽 2-2-2"},
- { id:223, parentId:22, name:"随意拖拽 2-2-3"},
- { id:23, parentId:2, name:"随意拖拽 2-3"}
- ];
-
-
- function initComplete(){
- $.fn.zTree.init($("#tree-1"), setting1, zNodes1);
- }
-
- //实现树的拖放,这个方法是必须的
- function beforeDrag1(treeId, treeNodes) {
- for (var i = 0, l = treeNodes.length; i < l; i++) {
- if(treeNodes[i].drag === false) {
- return false;
- }
- }
- return true;
- }
-
- //实现树的拖放,这个方法是必须的
- function beforeDrop1(treeId, treeNodes, targetNode, moveType) {
- return targetNode ? targetNode.drop !== false : true;
- }
-
-
- </script>
- </body>
- </html>
|