4
hao
2025-04-16 c5fb1fbcbb2bf4d511773d348f9ef625855c61fc
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<HTML>
<HEAD>
    <TITLE> ZTREE DEMO - fuzzySearch</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.exhide.js"></script>
    <script type="text/javascript" src="../../js/fuzzysearch.js"></script>
    
    <SCRIPT type="text/javascript">
        var setting = {
                check: {
                    enable: true//checkbox
                },
                view: {
                    nameIsHTML: true, //允许name支持html                
                    selectedMulti: false
                },
                edit: {
                    enable: false,
                    editNameSelectAll: false
                },
                data: {
                    simpleData: {
                        enable: true
                    }
                }
        };
 
        var zNodes =[
            { id:1, pId:0, name:"模糊搜索演示 1", t:"id=1", open:true},
            { id:11, pId:1, name:"[]\\^$.|?*+():关键字可以是js正则元字符", t:"id=11"},
            { id:12, pId:1, name:"{}<>'\"~`!@#%&-;:/,=:关键字可以是其他字符", t:"id=12"},
            { id:2, pId:0, name:"模糊搜索演示 2", t:"id=2", open:true},
            { id:21, pId:2, name:"大写ABDEFGHINQRT:关键字查找不区分大小写", t:"id=21"},
            { id:22, pId:2, name:"小写abdefghinqrt:关键字查找不区分大小写", t:"id=21"},
            { id:3, pId:0, name:"模糊搜索演示 3", t:"id=3", open:true },
            { id:31, pId:3, name:"空 格:关键字是空格", t:"id=31"}
        ];
 
        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            fuzzySearch('treeDemo','#key',null,true); //初始化模糊搜索方法
        });
        //-->
    </SCRIPT>
</HEAD>
 
<BODY>
<h1>根据关键字模糊查找节点</h1>
<h6>[ 文件路径: super/fuzzySearch.html ]</h6>
<div class="content_wrap">
    <div class="zTreeDemoBackground left">
        <ul id="treeDemo" class="ztree"></ul>
    </div>
    <div class="right">
        <ul class="info">
            <li class="title">
                <h2>1、fuzzySearch()方法使用说明</h2>
                <ul class="list">
                <li class="highlight_red">
                     @param zTreeId ztree对象的id,不需要#
                </li>
                <li class="highlight_red">
                    @param searchField 输入框选择器
                </li>
                <li class="highlight_red">
                    @param isHighLight 是否高亮,默认高亮,传入false禁用
                </li>
                <li class="highlight_red">
                    @param isExpand 是否展开,默认合拢,传入true展开
                </li>
                <li class="highlight_red">
                    fuzzySearch ( zTreeId, searchField, isHighLight, isExpand )
                </li>
                <li><p>搜索试试看:<br/>
                        关键字:<input type="text" id="key" value="" class="empty" placeholder="请输入关键字"/><br/>
                    </p>
                </li>
                </ul>
            </li>
            <li class="title"><h2>2、依赖的js</h2>
                <ul class="list">
                    <li>ztree v3.5.19.1及以上,使用到getPath()方法</li>
                    <li>ztree.exhide扩展,使用到hideNode()方法</li>
                </ul>
            </li>
        </ul>
    </div>
</div>
</BODY>
</HTML>