• zTree实现多选树


    zTree实现多选树


    1、实现源码

    <!DOCTYPE html>
    <html>
    <head>
    	<title>多选树</title>
    	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    	<link rel="stylesheet" type="text/css" href="../../../css/demo.css">
    	<link rel="stylesheet" type="text/css" href="../../../css/zTreeStyle/zTreeStyle.css">
    	<script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
    	<script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
    	<script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
    	<script type="text/javascript">
    		<!--
    		var setting = {
    			check: {
    				enable: true,
    				chkStyle: "checkbox",
    				chkboxType: { "Y": "s", "N": "ps" }
    			},
    			data: {
    				simpleData: {
    					enable: true
    				}
    			}
    		};
    
    		var zNodes =[
    			{ id:1, pId:0, name:"湖北省", open:true},
    			{ id:11, pId:1, name:"武汉市", open:true},
    			{ id:111, pId:11, name:"汉口"},
    			{ id:112, pId:11, name:"武昌"},
    			{ id:12, pId:1, name:"黄石市", open:true},
    			{ id:121, pId:12, name:"黄石港区"},
    			{ id:122, pId:12, name:"西塞山区"},
    			{ id:2, pId:0, name:"湖南省", open:true},
    			{ id:21, pId:2, name:"长沙市"},
    			{ id:22, pId:2, name:"株洲市", open:true},
    			{ id:221, pId:22, name:"天元区"},
    			{ id:222, pId:22, name:"荷塘区"},
    			{ id:23, pId:2, name:"湘潭市"}
    		];
    		
    		$(document).ready(function(){
    			$.fn.zTree.init($("#treeMultiple"), setting, zNodes);
    		});
    		//-->
    	</script>
    </head>
    
    <body>
    <div class="content_wrap" style="text-align: center;">
    	<div class="zTreeDemoBackground left">
    		<ul id="treeMultiple" class="ztree" style="height: 300px; 150px; overflow-y: auto"></ul>
    	</div>
    </div>
    </body>
    </html>

    2、实现结果



    3、源码说明

    (1)Y、N、"p"和“s”说明

    Y 属性定义 checkbox 被勾选后的情况; 
    N 属性定义 checkbox 取消勾选后的情况; 
    "p" 表示操作会影响父级节点; 
    "s" 表示操作会影响子级节点。


    (2)chkboxType: { "Y": "s", "N": "ps" }

            表示checkbox勾选操作,只影响子节点;取消勾选操作,影响父子节点

  • 相关阅读:
    前端水印
    canvas中图片大小自适应
    了解CSS变量var
    vue报错Adjacent JSX elements must be wrapped in an enclosing tag.
    修改Batch3DModelContent的片元着色器:让白模穿品如的衣服
    Cesium 顶点着色器中求解模型坐标
    Centos6.5部署及yum源注意事项
    linux常用命令
    复旦大学数学学院 18 级本科生对高等代数学习方法指导书的评价
    复旦大学数学学院 17 级本科生对高等代数学习方法指导书的评价
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315111.html
Copyright © 2020-2023  润新知