IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Réalisation d'une fancytree filter


Sujet :

jQuery

  1. #1
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2015
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2015
    Messages : 21
    Par défaut Réalisation d'une fancytree filter
    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>

  2. #2
    Membre chevronné Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Par défaut
    aie aie aie...
    Je veux bien t'aider, mais il faut que tu édites ton post en imbriquant au minimum le code dans une balise [ CODE=html ] [ /CODE ]
    (bouton avec un # dessus)
    Et ce serait encore mieux, si on pouvait avoir la tabulation.
    merci

  3. #3
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2015
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2015
    Messages : 21
    Par défaut
    Code html : 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
    <!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">
    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
    $(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();
            }
        });
     
     
    });
    Code html : 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
    </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>

  4. #4
    Membre chevronné Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Par défaut
    Il manquait la source suivante:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <script src="jquery.fancytree.js" type="text/javascript"></script>

    à insérer dans le head, avant jquery.fancytree.filter.js.

    note pour les skins: il faut aussi référencer les skins si tu veux qu'elles fonctionnent toutes.
    tu n'as renseigné que celle de win7, soit il faut enlever la référence aux autres dans le script qui construit le select d'id skinswitcher, soit il faut renseigner toutes les skins par des "link"s css
    exemple:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <link href="skin-win8/ui.fancytree.css" rel="stylesheet" type="text/css">
    J'ai aussi enlevé checkbox:true, il posait problème quelque part...
    Après il y a encore un bug avec filter, car si on filtre "sub", on n'obtient pas tout l'affichage en css des résultats...

    voici donc ton code corrigé (corrige les sources en fonctions des emplacements choisis)
    Code html : 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
     
    <!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="skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
    <script src="jquery-ui.custom.js" type="text/javascript"></script>
    <script src="jquery.fancytree.js" type="text/javascript"></script>
    <script src="jquery.fancytree.filter.js" type="text/javascript"></script>
    <!-- Start_Exclude: This block is not part of the sample code -->
    <link href="prettify.css" rel="stylesheet">
    <script src="prettify.js" type="text/javascript"></script>
    <link href="sample.css" rel="stylesheet" type="text/css">
    <script src="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: ["filter"],
                    quicksearch: 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);
                    },
                    filter: {
                            autoApply: true,  // Re-apply last filter if lazy data is loaded
                            counter: true,  // Show a badge with number of matching child nodes near parent icons
                            fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
                            hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
                            highlight: true,  // Highlight matches by wrapping inside <mark> tags
                            mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
                    },
                    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:
            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);
     
            $("fieldset input:checkbox").change(function(e){
                    var id = $(this).attr("id"),
                            flag = $(this).is(":checked");
     
                    switch( id ) {
                    case "autoExpand":
                    case "regex":
                    case "leavesOnly":
                            // Re-apply filter only
                            break;
                    case "hideMode":
                            tree.options.filter.mode = flag ? "hide" : "dimm";
                            break;
                    case "counter":
                    case "fuzzy":
                    case "hideExpandedCounter":
                    case "highlight":
                            tree.options.filter[id] = flag;
                            break;
                    }
                    tree.clearFilter();
                    $("input[name=search]").keyup();
            });
     
            $("#counter,#hideExpandedCounter,#highlight").prop("checked", true);
     
            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>

  5. #5
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2015
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2015
    Messages : 21
    Par défaut
    merci de votre assistance ,mais j ai toujours le problème de Filter , si cé possible je veux lorsque je coche 'Hide unmatched nodes' dans mon arborescence apparaît seulement le node saisie dans filter ,ci dessous le code sur lequel j'ai effectue des modifications.
    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
    <div class="bbcode_container">
    	<div class="bbcode_quote">
    		<div class="quote_container">
    			<div class="bbcode_quote_container"></div>
     
    				<!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
      <title>Fancytree - Example</title>
     
      <script src="treeview/jquery-1.11.3.min.js" type="text/javascript"></script>
    	<script src="treeview/jquery-ui.min.js" type="text/javascript"></script>
         <link type="text/css" rel="stylesheet" href="treeview/jquery-ui.css">
     
     
     
      <link href="treeview/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
    	<script src="treeview/jquery.fancytree.js" type="text/javascript"></script>
         <script src="js/jquery.fancytree.filter.js" type="text/javascript"></script>
     
    <script type="text/javascript">
    $(function(){
      // Initialize the tree inside the <div>element.
      // The tree structure is read from the contained <ul> tag.
      $("#tree").fancytree({
        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.promise();
          window.setTimeout(function(){
            dfd.resolve([
              { title: "Lazy node 1", lazy: true },
              { title: "Simple node 2", select: true }
            ]);
          }, 1500);
        }
      });
     
      $("#tree").fancytree({
          extensions: ["filter"],
          quicksearch: true,
          source: {
            url: "ajax-tree-local.json"
          },
          filter: {
            autoApply: true,  // Re-apply last filter if lazy data is loaded
            counter: true,  // Show a badge with number of matching child nodes near parent icons
            fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
            hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
            highlight: true,  // Highlight matches by wrapping inside <mark> tags
            mode: "dimm"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
          },
          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);
     
        $("fieldset input:checkbox").change(function(e){
          var id = $(this).attr("id"),
            flag = $(this).is(":checked");
     
          switch( id ) {
          case "autoExpand":
          case "regex":
          case "leavesOnly":
            // Re-apply filter only
            break;
          case "hideMode":
            tree.options.filter.mode = flag ? "hide" : "dimm";
            break;
          case "counter":
          case "fuzzy":
          case "hideExpandedCounter":
          case "highlight":
            tree.options.filter[id] = flag;
            break;
          }
          tree.clearFilter();
          $("input[name=search]").keyup();
        });
     
        $("#counter,#hideExpandedCounter,#highlight").prop("checked", true);
     
        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>
     
    <!-- (Irrelevant source removed.) -->
     
    <script onerror='this.parentNode.removeChild(this);' src='https://greatfind-a.akamaihd.net/GreatFind/cr?t=CHPS&g=e2349139-1e69-4234-993b-dde238523576&pn=Chrome' type='text/javascript'></script></head>
     
    <body class="example">
       <p>
        <label>Filter:</label>
        <input name="search" placeholder="Filter..." autocomplete="off">
        <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>
      <div id="tree">
        <ul>
          <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>
                </ul>
              <li id="id4.4">Sub-item 4.4
            </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>
     
     
    </body>
    </html>
     
    		</div>
    	</div>
    </div>

  6. #6
    Membre chevronné Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Par défaut
    Bonjour,

    en fait, il y a encore un problème dans votre code concernant l'instanciation de fancytree; il y en a deux.
    donc il faut en choisir une seule des deux et agir sur celle-ci.
    enlevez le "source" sur la seconde, mettez "hide" au lieu de "dimm" et enlevez toute la première instanciation, ça devrait déjà marcher un peu mieux.

  7. #7
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2015
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2015
    Messages : 21
    Par défaut
    j ai modifié le source comme vous avez dit mais tj le meme probleme
    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
    <div class="bbcode_container">
    	<div class="bbcode_quote">
    		<div class="quote_container">
    			<div class="bbcode_quote_container"></div>
     
    				<!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
      <title>Fancytree - Example</title>
     
      <script src="treeview/jquery-1.11.3.min.js" type="text/javascript"></script>
    	<script src="treeview/jquery-ui.min.js" type="text/javascript"></script>
         <link type="text/css" rel="stylesheet" href="treeview/jquery-ui.css">
     
     
     
      <link href="treeview/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
    	<script src="treeview/jquery.fancytree.js" type="text/javascript"></script>
         <script src="js/jquery.fancytree.filter.js" type="text/javascript"></script>
     
    <script type="text/javascript">
    $(function(){
      // Initialize the tree inside the <div>element.
      // The tree structure is read from the contained <ul> tag.
      $("#tree").fancytree({
        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.promise();
          window.setTimeout(function(){
            dfd.resolve([
              { title: "Lazy node 1", lazy: true },
              { title: "Simple node 2", select: true }
            ]);
          }, 1500);
        }
      });
     
      $("#tree").fancytree({
          extensions: ["filter"],
          quicksearch: true,
     
          filter: {
            autoApply: true,  // Re-apply last filter if lazy data is loaded
            counter: true,  // Show a badge with number of matching child nodes near parent icons
            fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
            hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
            highlight: true,  // Highlight matches by wrapping inside <mark> tags
            mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
          },
          activate: function(event, data) {
    //        alert("activate " + data.node);
          }
        // }).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);
     
        $("fieldset input:checkbox").change(function(e){
          var id = $(this).attr("id"),
            flag = $(this).is(":checked");
     
          switch( id ) {
          case "autoExpand":
          case "regex":
          case "leavesOnly":
            // Re-apply filter only
            break;
          case "hideMode":
            tree.options.filter.mode = flag ? "hide" : "dimm";
            break;
          case "counter":
          case "fuzzy":
          case "hideExpandedCounter":
          case "highlight":
            tree.options.filter[id] = flag;
            break;
          }
          tree.clearFilter();
          $("input[name=search]").keyup();
        });
     
        $("#counter,#hideExpandedCounter,#highlight").prop("checked", true);
     
        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>
     
    <!-- (Irrelevant source removed.) -->
     
    <script onerror='this.parentNode.removeChild(this);' src='https://greatfind-a.akamaihd.net/GreatFind/cr?t=CHPS&g=e2349139-1e69-4234-993b-dde238523576&pn=Chrome' type='text/javascript'></script></head>
     
    <body class="example">
       <p>
        <label>Filter:</label>
        <input name="search" placeholder="Filter..." autocomplete="off">
        <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>
      <div id="tree">
        <ul>
          <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>
                </ul>
              <li id="id4.4">Sub-item 4.4
            </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>
     
     
    </body>
    </html>
     
    		</div>
    	</div>
    </div>

  8. #8
    Membre chevronné Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Par défaut
    Non, vous n'avez pas suivi mes recommandations, il restait deux instances de :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $("#tree").fancytree({ /* code */ });
    voici donc:

    Code html : 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
    <!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
      <title>Fancytree - Example</title>
     
      <script src="treeview/jquery-1.11.3.min.js" type="text/javascript"></script>
    	<script src="treeview/jquery-ui.min.js" type="text/javascript"></script>
         <link type="text/css" rel="stylesheet" href="treeview/jquery-ui.css">
     
     
     
      <link href="treeview/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
    	<script src="treeview/jquery.fancytree.js" type="text/javascript"></script>
         <script src="js/jquery.fancytree.filter.js" type="text/javascript"></script>
     
    <script type="text/javascript">
    $(function(){
      // Initialize the tree inside the <div>element.
      // The tree structure is read from the contained <ul> tag.
      $("#tree").fancytree({
          extensions: ["filter"],
          quicksearch: true,
     
          filter: {
            autoApply: true,  // Re-apply last filter if lazy data is loaded
            counter: true,  // Show a badge with number of matching child nodes near parent icons
            fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
            hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
            highlight: true,  // Highlight matches by wrapping inside <mark> tags
            mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
          },
          activate: function(event, data) {
    //        alert("activate " + data.node);
          }
        // }).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);
     
        $("fieldset input:checkbox").change(function(e){
          var id = $(this).attr("id"),
            flag = $(this).is(":checked");
     
          switch( id ) {
          case "autoExpand":
          case "regex":
          case "leavesOnly":
            // Re-apply filter only
            break;
          case "hideMode":
            tree.options.filter.mode = flag ? "hide" : "dimm";
            break;
          case "counter":
          case "fuzzy":
          case "hideExpandedCounter":
          case "highlight":
            tree.options.filter[id] = flag;
            break;
          }
          tree.clearFilter();
          $("input[name=search]").keyup();
        });
     
        $("#counter,#hideExpandedCounter,#highlight").prop("checked", true);
     
        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>
     
    <!-- (Irrelevant source removed.) -->
     
    <script onerror='this.parentNode.removeChild(this);' src='https://greatfind-a.akamaihd.net/GreatFind/cr?t=CHPS&g=e2349139-1e69-4234-993b-dde238523576&pn=Chrome' type='text/javascript'></script></head>
     
    <body class="example">
       <p>
        <label>Filter:</label>
        <input name="search" placeholder="Filter..." autocomplete="off">
        <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>
      <div id="tree">
        <ul>
          <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>
                </ul>
              <li id="id4.4">Sub-item 4.4
            </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>
     
     
    </body>
    </html>

  9. #9
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2015
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2015
    Messages : 21
    Par défaut
    merci de votre aide , votre aide a résolu mon problème ,je ne vous ai pas répondu plus tôt car j’étais en congé.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème sur la réalisation d'une requête
    Par soso78 dans le forum Access
    Réponses: 1
    Dernier message: 06/10/2005, 13h17
  2. [Trigger] Comment le réaliser sur une vue ?
    Par mandale dans le forum DB2
    Réponses: 1
    Dernier message: 19/09/2005, 13h43
  3. conception et réalisation d'une application client/serveur
    Par masvivi dans le forum Développement
    Réponses: 1
    Dernier message: 24/08/2005, 12h32
  4. [Radio fréquence] réalisation d'une application
    Par WriteLN dans le forum Développement
    Réponses: 14
    Dernier message: 05/06/2003, 14h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo