标签:单击 root link white 父节点 双击 checkbox select orm
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 6 <title>Title</title> 7 <link href="JS/tool/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" /> 8 <script src="JS/jquery-1.11.1.min.js"></script> 9 <script src="JS/tool/zTree/js/jquery.ztree.core-3.5.js"></script> 10 <script src="JS/tool/zTree/js/jquery.ztree.excheck-3.5.js"></script> 11 12 </head> 13 <body style="background: #ddd;"> 14 <div class="mainbody-left"> 15 <div class="vvtree dept-tree left"> 16 <ul id="menu_tree_left" class="ztree"></ul> 17 </div> 18 </div> 19 <script> 20 var settingLeft = { 21 view: { 22 dblClickExpand: false,//双击节点时,是否自动展开父节点的标识 23 showLine: false,//是否显示节点之间的连线 24 showIcon: true, 25 fontCss: { ‘color‘: ‘white‘, ‘font-weight‘: ‘normal‘ },//字体样式函数 26 selectedMulti: false //设置是否允许同时选中多个节点 27 }, 28 check: { 29 //chkboxType: { "Y": "ps", "N": "ps" }, 30 chkStyle: "checkbox",//复选框类型 31 enable: false //每个节点上是否显示 CheckBox 32 }, 33 data: { 34 simpleData: {//简单数据模式 35 enable: true, 36 idKey: "id", 37 pIdKey: "pId", 38 rootPId: "" 39 } 40 }, 41 callback: { 42 43 beforeClick: function (treeId, treeNode) { 44 zTree = $.fn.zTree.getZTreeObj("menu_tree_vehicle"); 45 if (treeNode.isParent) { 46 zTree.expandNode(treeNode);//如果是父节点,则展开该节点 47 } else { 48 zTree.checkNode(treeNode, !treeNode.checked, true, true);//单击勾选,再次单击取消勾选 49 } 50 }//, 51 // onCheck: onCheck 52 53 } 54 }; 55 56 $(function () { 57 //初始化菜单树 58 var zNodes = [ 59 { id: 0, pId: -1, name: "一级部门", open: true }, 60 { id: 1, pId: 0, name: "二级部门1", open: false }, 61 { id: 2, pId: 1, name: "三级部门1" }, 62 { id: 3, pId: 1, name: "三级部门2" }, 63 { id: 4, pId: 0, name: "二级部门2", open: false }, 64 { id: 5, pId: 4, name: "三级部门3" }, 65 { id: 6, pId: 4, name: "三级部门4", open: false }, 66 { id: 7, pId: 6, name: "四级部门1" }, 67 { id: 8, pId: 6, name: "四级部门2" }, 68 { id: 9, pId: 0, name: "二级部门3" }, 69 { id: 10, pId: 0, name: "二级部门4" } 70 ]; 71 $.fn.zTree.init($("#menu_tree_left"), settingLeft, zNodes); 72 }); 73 </script> 74 </body> 75 76 </html>
完成!
标签:单击 root link white 父节点 双击 checkbox select orm
原文地址:http://www.cnblogs.com/yeqrblog/p/6346782.html