Bonjour à tous,

J'aimerai créer un tableau multi niveau en avec jquery.

mais mon icône s'affiche deux fois et je n'arrive pas à faire plusieurs sous niveau.

ci dessous mon code

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
<!DOCTYPE html>
<html>
 
<head>
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <title>Dept Emp</title>
 
   <link type='text/css' href='app/webroot/css/bootstrap/4.3.1/bootstrap.min.css' rel='stylesheet' />
   <link type='text/css' href='app/webroot/css/font-awesome/4.7/css/font-awesome.min.css' rel='stylesheet' />
   <link type='text/css' href="app/webroot/css/jquery-ui.min.css" type="text/css" />
   <link type='text/css' href="app/webroot/css/typeahead.css" type="text/css" />
   <link type='text/css' href="app/webroot/css/bootstrap-tagsinput.css" type="text/css" />
   <script src="app/webroot/js/jquery.min.js"></script>
   <!-- <script type="text/javascript" src="app/webroot/js/bootstrap/4.3.1/bootstrap.min.js"></script> -->
   <!-- jQuery UI CSS -->
   <link href="app/webroot/css/jquery-ui.css" type="text/css" rel="stylesheet">
   <!-- Tokenfield CSS -->
   <link href="app/webroot/css/bootstrap-tokenfield.css" type="text/css" rel="stylesheet"> <!-- Download link : https://www.htmllion.com/bootstrap-tokenfield-jQuery-tag-token-input-plugin.html Doc bootstrap tokenfield : https://sliptree.github.io/bootstrap-tokenfield/ -->
 
</head>
 
<body>
   <div id="container">
      <div id="content">
         <div class="container">
            <div class="row">
               <div class="row">
                  <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                     <div class="jumbotron">
                        <h1 class="display-4">Employe Dept</h1>
                        <h1 class="display-4">Recherche departement</h1>
                        <p class="lead"></p>
 
                  </div>
               </div>
            </div>
            <div class="row mb-2">
               <div class="row mb-2">
                  <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
                     <input type='text' id='jobs' name='job' value='' class='form-control' value="red,green,blue">
                  </div>
                  <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
                     <input id="reinit" class="btn btn-primary" type="button" value="REINITIALISER" style="float:left">
                  </div>
                  <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
                     <input id="search" class="btn btn-primary" type="button" value="RECHERCHER">
                  </div>
               </div>
            </div>
            <div class="row">
               <div id="reinit2" class="col-lg-3 col-md-6 col-sm-12 col-xs-12 " role="button">
                  <div class="row ">
                     <table id="user_data" class="table table-bordered table-striped" style="width:100%">
                        <thead>
                           <tr class="header">
                              <th style="width:100px">Nom Employe</th>
                              <th style="width:100px">Adresse Employe</th>
                              <th style="width:100px">Bloc fonctionnel</th>
                              <th style="width:100px">Etat</th>
                           </tr>
                        </thead>
                        <tbody>
                        </tbody>
                     </table>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <div id="footer"></div>
 
   </div>
   <script type="text/javascript" src="app/webroot/js/jquery-1.12.4.min.js"></script>
   <script type="text/javascript" src="app/webroot/js/bootstrap/4.3.1/bootstrap.min.js"></script>
   <script type="text/javascript" src="app/webroot/js/jquery-ui.js"></script>
   <script type="text/javascript" src="app/webroot/js/bootstrap-tokenfield.js"></script>
 
   <script>
 
    var jsonData = '[{"id":"ajson1","parent":"#","level":"1", "name":"job1","adr":"part1","bloc":"bloc1","etat":"Et1"},{"id":"ajson2","parent":"#","level":"1", "name":"job2","adr":"part2","bloc":"bloc2","etat":"Et2"},{"id":"ajson3","parent":"ajson2","level":"2", "name":"job21","adr":"part21","bloc":"bloc21","etat":"Et21"},{"id":"ajson4","parent":"ajson2","level":"2", "name":"job22","adr":"part22","bloc":"bloc22","etat":"Et22"}]';
 
    jsonData = $.parseJSON(jsonData);
 
    var trHTML = '';
    $.each(jsonData, function (i, item) {
        trHTML += '<tr data-id="'+item.id+'" data-parent="'+item.parent+'" data-level="'+item.level+'"><td data-column="name">' + item.name + '</td><td >' + item.adr +'</td><td >' + item.bloc + '</td><td >'+item.etat+'</td></tr>';
    });
    
    $('#user_data').append(trHTML);
 
    // Gestion de la tree table
 
   var
        $table = $('#user_data'),
        rows = $table.find('tr');
 
    rows.each(function (index, row) {
        var
            $row = $(row),
            level = $row.data('level'),
            id = $row.data('id'),
            $columnName = $row.find('td[data-column="name"]'),
            children = $table.find('tr[data-parent="' + id + '"]');
 
        if (children.length) {
            var expander = $columnName.prepend('' +
                '<span class="treegrid-expander  fa fa-chevron-right"></span>' +
                '');
 
            children.hide();
 
            expander.on('click', function (e) {
                var $target = $(e.target);
                if ($target.hasClass('fa fa-chevron-right')) {
                    $target
                        .removeClass('fa fa-chevron-right')
                        .addClass('fa fa-chevron-down');
 
                    children.show();
                } else {
                    $target
                        .removeClass('fa fa-chevron-down')
                        .addClass('fa fa-chevron-right');
 
                    reverseHide($table, $row);
                }
            });
        }
 
        $columnName.prepend('' +
            '<span class="treegrid-indent" style="width:' + 15 * level + 'px"></span>' +
            '');
    });
 
    // Reverse hide all elements
    reverseHide = function (table, element) {
        var
            $element = $(element),
            id = $element.data('id'),
            children = table.find('tr[data-parent="' + id + '"]');
 
        if (children.length) {
            children.each(function (i, e) {
                reverseHide(table, e);
            });
 
            $element
                .find('.fa fa-chevron-down')
                .removeClass('fa fa-chevron-down')
                .addClass('fa fa-chevron-right');
 
            children.hide();
        }
    };
 
   
   </script>
 
</body>
 
</html>

Quelqu'un saurait m'indiquer comment faire.