• ztree-demo


    <!DOCTYPE html>
    <HTML>
    <HEAD>
    <TITLE> ZTREE DEMO - Async</TITLE>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="css/demo.css" type="text/css">
    <link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="js/jquery.ztree.exedit.js"></script>
    </HEAD>

    <BODY>
    <ul id="treeDemo" class="ztree"></ul>
    <table>
    <tr>
    <td class="title"><a href="javascript:void(0)">test1</a></td>
    <td class="filePath">
    n1/n1.n1/n1.n1.n1/n1.n1.n1.n3<br>
    n3/n3.n2
    </td>
    </tr>
    <tr>
    <td class="title"><a href="javascript:void(0)">test2</a></td>
    <td class="filePath">
    n1/n1.n1/n1.n1.n1/n1.n1.n1.n4<br>
    n3/n3.n3.n1/n3.n3.n1.n2
    </td>
    </tr>
    </table>

    <SCRIPT type="text/javascript">
    <!--
    var setting = {
    check: {
    enable: true
    },
    async: {
    enable: true,
    url:"demo/cn/asyncData/getNodes.php",
    autoParam:["id", "name=n", "level=lv"],
    otherParam:{"otherParam":"zTreeAsyncTest"},
    dataFilter: filter
    },
    callback: {
    onAsyncSuccess: onAsyncSuccess
    }
    };

    var zTreeObj;
    $(document).ready(function(){
    zTreeObj = $.fn.zTree.init($("#treeDemo"), setting);
    });

    function filter(treeId, parentNode, childNodes) {
    if (!childNodes)
    return null;
    childNodes.forEach(function(childNode){
    // 计算路径
    var path = '';
    if(!parentNode){
    path = childNode.name;
    }else{
    path = parentNode.filePath + '/' + childNode.name;
    }
    childNode.filePath = path;

    // 判断是否已选中
    var checked = false;
    var halfCheck = false;
    var chkDisabled = false;
    $(".filePath").each(function(i, item){
    var filePathArray = $(item).text().trim().split(' ');
    filePathArray.forEach(function(filePath){
    filePath = filePath.trim();
    if(filePath == childNode.filePath){// 全匹配(叶节点)
    checked = true;
    if(jQuery.inArray(filePath,filterFilePathArray) < 0){
    chkDisabled = true;
    }
    }else if(filePath.indexOf(childNode.filePath) == 0){// 部分匹配(父节点)
    checked = true;
    // halfCheck = true;
    }
    });
    });
    childNode.checked = checked;
    childNode.halfCheck = halfCheck;
    childNode.chkDisabled = chkDisabled;
    });
    return childNodes;
    }

    function onAsyncSuccess(event, treeId, treeNode, msg) {
    }
    //-->
    </SCRIPT>


    <SCRIPT type="text/javascript">
    <!--
    var filterFilePathArray = [];

    $(document).ready(function(){
    $(".title a").click(function(){
    filterFilePathArray = [];
    var filePathArray = $(this).parents(".title").siblings(".filePath").text().trim().split(' ');
    filePathArray.forEach(function(filePath){
    filePath = filePath.trim();
    filterFilePathArray.push(filePath);
    });

    zTreeObj.destroy();
    zTreeObj = $.fn.zTree.init($("#treeDemo"), setting);
    });
    });
    //-->
    </SCRIPT>
    </BODY>
    </HTML>

  • 相关阅读:
    C#单例模式的三种写法转载
    silverlight 添加配置项
    oracle 如何实现上一条、下一条、查找不连续的值
    一个IT民工眼中的保障房不能保证公平,赞成取消保障房
    c# where 转载
    进度条 silverlight
    中国软件公司我深表认同:软硬结合
    计算经纬度两点之间的距离(c#)
    如何高效使用SQLITE .NET (C#)
    如何判断系统是否安装了flash插件
  • 原文地址:https://www.cnblogs.com/zyjzz/p/5755299.html
Copyright © 2020-2023  润新知