j 'utilise dans mon programme fancytree filter , et je veux lorsque je coche "Hide unmatched nodes" avoir l'affichage dans mon arborescence seulement le nom saisi dans le champ de saisie Filter , ce je n'arrive pas a le concrétiser merci de me donner un coup de main le code est le suivant :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	<title>Fancytree - Example: Filter</title>
 
	<script src="//code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
	<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
 
	<link href="treeview/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
	<script src="treeview/jquery-ui.custom.js" type="text/javascript"></script>
	<script src="filter/jquery.fancytree.filter.js" type="text/javascript"></script>
 
	<!-- Start_Exclude: This block is not part of the sample code -->
	<link href="filter/prettify.css" rel="stylesheet">
	<script src="filter/prettify.js" type="text/javascript"></script>
	<link href="treeview/sample.css" rel="stylesheet" type="text/css">
	<script src="treeview/sample.js" type="text/javascript"></script>
	<!-- End_Exclude -->
 
<style type="text/css">
</style>
 
<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
	$(function(){
 
 
	$("#tree").fancytree({
//            extensions: ['dnd'],
      checkbox: true,
		activate: function(event, data) {
			$("#echoActive").text(data.node.title);
//              alert(node.getKeyPath());
			if( data.node.url )
				window.open(data.node.url, data.node.target);
		},
		deactivate: function(event, data) {
			$("#echoSelected").text("-");
		},
		focus: function(event, data) {
			$("#echoFocused").text(data.node.title);
		},
		blur: function(event, data) {
			$("#echoFocused").text("-");
		},
		lazyLoad: function(event, data){
			// Simulate a slow ajax request
			var dfd = new $.Deferred()
			data.result = dfd;
			window.setTimeout(function(){
				dfd.resolve([
					{ title: 'Lazy node 1', lazy: true },
					{ title: 'Simple node 2', select: true }
				]);
			}, 1500);
		}
	});
  // Attach the fancytree widget to an existing <div id="tree"> element
		// and pass the tree options as an argument to the fancytree() function:
		$("#tree").fancytree({
			extensions: ["filter"],
			quicksearch: true,
 
			filter: {
				autoApply: true,
				// autoExpand: true,
				mode: "hide"
			},
			activate: function(event, data) {
//				alert("activate " + data.node);
			},
			lazyLoad: function(event, data) {
				data.result = {url: "ajax-sub2.json"}
			}
		// }).on("keydown", function(e){
		// 	var c = String.fromCharCode(e.which);
		// 	if( c === "F" && e.ctrlKey ) {
		// 		$("input[name=search]").focus();
		// 	}
		});
		var tree = $("#tree").fancytree("getTree");
		/*
		 * Event handlers for our little demo interface
		 */
		$("input[name=search]").keyup(function(e){
			var n,
				opts = {
					autoExpand: $("#autoExpand").is(":checked"),
					leavesOnly: $("#leavesOnly").is(":checked")
				},
				match = $(this).val();
			if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
				$("button#btnResetSearch").click();
				return;
			}
			if($("#regex").is(":checked")) {
				// Pass function to perform match
				n = tree.filterNodes(function(node) {
					return new RegExp(match, "i").test(node.title);
				}, opts);
			} else {
				// Pass a string to perform case insensitive matching
				n = tree.filterNodes(match, opts);
			}
			$("button#btnResetSearch").attr("disabled", false);
			$("span#matches").text("(" + n + " matches)");
		}).focus();
		$("button#btnResetSearch").click(function(e){
			$("input[name=search]").val("");
			$("span#matches").text("");
			tree.clearFilter();
		}).attr("disabled", true);
		$("input#hideMode").change(function(e){
			tree.options.filter.mode = $(this).is(":checked") ? "hide" : "dimm";
			tree.clearFilter();
			$("input[name=search]").keyup();
		}).prop("checked", true);
		$("input#autoExpand").change(function(e){
			tree.clearFilter();
			$("input[name=search]").keyup();
		}).prop("checked", true);
		$("input#leavesOnly").change(function(e){
		//	tree.options.filter.leavesOnly = $(this).is(":checked");
			tree.clearFilter();
			$("input[name=search]").keyup();
		});
		$("input#regex").change(function(e){
			tree.clearFilter();
			$("input[name=search]").keyup();
		});
		addSampleButton({
			label: "Filter active branch",
			newline: false,
			code: function(){
				if( !tree.getActiveNode() ) {
					alert("Please activate a folder.");
					return;
				}
				tree.filterBranches(function(node){
					return node.isActive();
				});
			}
		});
		addSampleButton({
			label: "Reset filter",
			newline: false,
			code: function(){
				tree.clearFilter();
			}
		});
 
 
	});
</script>
</head>
<body class="example">
	<h1>Example: 'filter' extension</h1>
	<div class="description">
		<p>
			Allow to dimm or hide nodes based on a matching expression.
		</p>
		<p>
			<b>Status:</b> beta.
			<b>Details:</b>
			<a href="https://github.com/mar10/fancytree/wiki/ExtFilter"
				target="_blank" class="external">ext-filter</a>.
		</p>
	</div>
	<div>
		<label for="skinswitcher">Skin:</label> <select id="skinswitcher"></select>
	</div>
	<p>
		<label>Filter:</label>
		<input name="search" placeholder="Filter...">
		<button id="btnResetSearch">&times;</button>
		<span id="matches"></span>
	</p>
	<p>
		<label for="hideMode">
			<input type="checkbox" id="hideMode">
			Hide unmatched nodes
		</label>
		<label for="leavesOnly">
			<input type="checkbox" id="leavesOnly">
			Leaves only
		</label>
		<label for="autoExpand">
			<input type="checkbox" id="autoExpand">
			Auto expand
		</label>
		<label for="regex">
			<input type="checkbox" id="regex">
			Regular expression
		</label>
	</p>
	<p id="sampleButtons">
	</p>
	<!-- Add a <table> element where the tree should appear: -->
	<div id="tree">
      <ul id="options">
			<li>This simple node (and the following) have been created from html.
			<li id="id1" title="This is item #1">item1 with key and tooltip
			<li id="id2">item2 with key "id2"
 
			<li id="id3" class="folder">Standard Folder with some children
				<ul>
					<li id="id3.1">Sub-item 3.1
					<li id="id3.2">Sub-item 3.2
				</ul>
 
			<li id="id4">item 4. Note that also non-folders (i.e. 'documents') may have child nodes
				<ul>
					<li id="id4.1">Sub-item 4.1
					<li id="id4.2">Sub-item 4.2
					<li id="id4.3">Sub-item 4.3
						<ul>
							<li id="id4.3.1">Sub-item 4.3.1
							<li id="id4.3.2">Sub-item 4.3.2
							<ul>
								<li id="id4.3.2.1">Sub-item 4.3.2.1
								<li id="id4.3.2.2">Sub-item 4.3.2.2
                                <ul>
                                  <li id="id4.3.2.1">Sub-item 4.3.2.1.1
								<li id="id4.3.2.2">Sub-item 4.3.2.2.2
                                </ul>
							</ul>
						</ul>
					<li id="id4.4">Mory
				</ul>
 
			<li id="id5" class="expanded folder">Advanced examples
				<ul>
					<li data="key: 'node5.1'">item5.1: Using data attribute as an alternative way to specify a key.
					<li data="key: 'node5.3', folder: true">item5.1: Using data attribute as an alternative way to specify a folder.
					<li id="id5.2">Sub-item 5.2
					<li>Item without a key. Keys are optional (generated automatically), but may be used in the callbacks
				</ul>
		</ul>
	</div>
 
	<!-- Start_Exclude: This block is not part of the sample code -->
	<hr>
	<p class="sample-links  no_code">
		<a class="hideInsideFS" href="https://github.com/mar10/fancytree">jquery.fancytree.js project home</a>
		<a class="hideOutsideFS" href="#">Link to this page</a>
		<a class="hideInsideFS" href="index.html">Example Browser</a>
		<a href="#" id="codeExample">View source code</a>
	</p>
	<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
	<!-- End_Exclude -->
</body>
</html>