1
hao
2025-05-20 8e24c6fea30d9b179375ee2893710cdec2443b13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<HTML>
<HEAD>
    <TITLE> ZTREE DEMO - Async</TITLE>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type">
    <link href="../../../css/demo.css" rel="stylesheet" type="text/css">
    <link href="../../../css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css">
    <script src="../../../js/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../../../js/jquery.ztree.core.js" type="text/javascript"></script>
    <!--  <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
      <script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>-->
    <SCRIPT type="text/javascript">
        <!--
        var setting = {
            async: {
                enable: true,
                url:"../asyncData/getNodes.php",
                autoParam:["id", "name=n", "level=lv"],
                otherParam:{"otherParam":"zTreeAsyncTest"},
                dataFilter: filter
            }
        };
 
        function filter(treeId, parentNode, childNodes) {
            if (!childNodes) return null;
            for (var i=0, l=childNodes.length; i<l; i++) {
                childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
            }
            return childNodes;
        }
 
        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting);
        });
        //-->
    </SCRIPT>
</HEAD>
 
<BODY>
<h1>Dynamic Tree with Ajax</h1>
<h6>[ File Path: core/async.html ]</h6>
<div class="content_wrap">
    <div class="zTreeDemoBackground left">
        <ul class="ztree" id="treeDemo"></ul>
    </div>
    <div class="right">
        <ul class="info">
            <li class="title"><h2>1, Explanation of setting</h2>
                <ul class="list">
                <li class="highlight_red">For create dynamic tree with ajax,  you need to set attributes in setting.async, see the API documentation for more related contents.</li>
                </ul>
            </li>
            <li class="title"><h2>2, Explanation of treeNode</h2>
                <ul class="list">
                <li>Dynamic tree with ajax doesn't need to make special treeNode node data, if use simple JSON data model, please set the attributes in setting.data.simple.</li>
                <li>If ajax only to return node data in single level, you don't need to use simple JSON data model.</li>
                </ul>
            </li>
            <li class="title"><h2>3、Other explanation</h2>
                <ul class="list">
                <li class="highlight_red">Monitoring autoParam and otherParam use firebug or the developer tools in browser.</li>
                <li class="highlight_red">This Demo only loading 4 level nodes (level = 3).</li>
                <li class="highlight_red">This Demo use 'dataFilter' to modify the name of the node.</li>
                </ul>
            </li>
        </ul>
    </div>
</div>
</BODY>
</HTML>