Bonjour,
J'ai le code HTML suivant, qui est généré par une Grid de la librarie Telerik ASP.NET MVC:
Cette grille sert à afficher des données sous forme hiérarchique, avec 3 niveaux (A, B, C) :
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
253
254
255
256
257
258
259
260 <div class="k-grid k-widget" id="grid" style="width: 95%;" data-role="grid"> <div class="k-grid-header" style="padding-right: 12px;"> <div class="k-grid-header-wrap"> <table role="grid"> <colgroup> <col class="k-hierarchy-col"> <col style="width:25px"> <col> </colgroup> <thead role="rowgroup"> <tr role="row"> <th class="k-hierarchy-cell k-header"> </th> <th class="k-header" id="8bb1836e-aaab-44fc-8a18-f9d9ecc8f5c3" role="columnheader" rowspan="1" data-index="0"/> <th class="k-header" id="122822f9-7746-479c-a8da-a3a64c5ead7e" role="columnheader" rowspan="1" data-role="columnsorter" data-index="1" data-title="Level A - Column A" data-field="Name"> <a class="k-link" href="#">Level A - Column A</a> </th> </tr> </thead> </table> </div> </div> <div class="k-grid-content"> <table class="k-selectable" role="treegrid" aria-multiselectable="true" data-role="selectable"> <colgroup> <col class="k-hierarchy-col"> <col style="width:25px"> <col> </colgroup> <tbody role="rowgroup"> <tr class="k-master-row k-state-selected" role="row" aria-selected="true" data-uid="1ee43ddd-c8cd-41ed-b7d6-bf8b77d460a3"> <td class="k-hierarchy-cell"> <a tabindex="-1" class="k-icon k-minus" href="#"/> </td> <td role="gridcell"> <input class="checkbox niveauA" type="checkbox"> </td> <td role="gridcell">Company A</td> </tr> <tr class="k-detail-row"> <td class="k-hierarchy-cell"/> <td class="k-detail-cell" colspan="2"> <div class="fundsGrid k-grid k-widget" data-role="grid"> <div class="k-grid-header" style="padding-right: 12px;"> <div class="k-grid-header-wrap"> <table role="grid"> <colgroup> <col class="k-hierarchy-col"> <col style="width:30px"> <col style="width:650px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> </colgroup> <thead role="rowgroup"> <tr role="row"> <th class="k-hierarchy-cell k-header"> </th> <th class="k-header" id="26cf3ae3-c5df-40e0-b591-a750bd71742a" role="columnheader" rowspan="1" data-index="0"/> <th class="k-header" id="1213c2ca-57ac-4c24-835f-417ce9b6a0ba" role="columnheader" rowspan="1" data-role="columnsorter" data-index="1" data-title="Level B - Column A" data-field="LevelB-ColumnA"> <a class="k-link" href="#">Level B - Column A</a> </th> <th class="k-header" id="cc711bc1-4ede-43fd-b20b-c3cfcfd3782b" role="columnheader" rowspan="1" data-role="columnsorter" data-index="2" data-title="Level B - Column B" data-field="LevelB-ColumnB"> <a class="k-link" href="#">Level B - Column B</a> </th> <th class="k-header" id="712b4a70-d03f-41ec-80fd-59e236ef80ba" role="columnheader" rowspan="1" data-role="columnsorter" data-index="3" data-title="Level B - Column C" data-field="LevelB-ColumnC"> <a class="k-link" href="#">Level B - Column C</a> </th> <th class="k-header" id="eab11121-dd87-48a9-9706-fbc6ec4c9ca1" role="columnheader" rowspan="1" data-role="columnsorter" data-index="4" data-title="Level B - Column D" data-field="LevelB-ColumnD"> <a class="k-link" href="#">Level B - Column D</a> </th> <th class="k-header" id="98ccc9d0-e5ea-4c3f-91ad-0187f0f67791" role="columnheader" rowspan="1" data-role="columnsorter" data-index="5" data-title="Level B - Column E" data-field="LevelB-ColumnE"> <a class="k-link" href="#">Level B - Column E</a> </th> <th class="k-header" id="146db445-b90a-4386-a36c-01c9e2495c4f" role="columnheader" rowspan="1" data-role="columnsorter" data-index="6" data-title="Level B - Column F" data-field="LevelB-ColumnF"> <a class="k-link" href="#">Level B - Column F</a> </th> <th class="k-header" id="a0669011-428c-41b8-8722-1a585da5edf6" role="columnheader" rowspan="1" data-role="columnsorter" data-index="7" data-title="Level B - Column G" data-field="LevelB-ColumnG"> <a class="k-link" href="#">Level B - Column G</a> </th> <th class="k-header" id="5a5c72db-9d58-4362-8c61-3c72c6f2a7d1" role="columnheader" rowspan="1" data-role="columnsorter" data-index="8" data-title="Level B - Column H" data-field="LevelB-ColumnH"> <a class="k-link" href="#">Level B - Column H</a> </th> <th class="k-header" id="9ef69f85-ca6e-46d0-abc3-c547daab3317" role="columnheader" rowspan="1" data-role="columnsorter" data-index="9" data-title="Level B - Column I" data-field="LevelB-ColumnI"> <a class="k-link" href="#">Level B - Column I</a> </th> <th class="k-header" id="4a02d2f9-3f04-4706-a0fa-cacb08b12fb4" role="columnheader" rowspan="1" data-role="columnsorter" data-index="10" data-title="Level B - Column J" data-field="LevelB-ColumnJ"> <a class="k-link" href="#">Level B - Column J</a> </th> <th class="k-header" id="ec3d4bca-c1b0-4fb9-b3b9-b5972629faf1" role="columnheader" rowspan="1" data-role="columnsorter" data-index="11" data-title="Level B - Column K" data-field="LevelB-ColumnK"> <a class="k-link" href="#">Level B - Column K</a> </th> <th class="k-header" id="9b46cf71-d8fe-4259-ad65-174d6eb533ba" role="columnheader" rowspan="1" data-role="columnsorter" data-index="12" data-title="Level B - Column L" data-field="LevelB-ColumnL"> <a class="k-link" href="#">Level B - Column L</a> </th> <th class="k-header" id="1f9919d5-1c17-40d3-b734-26bad4a42ca8" role="columnheader" rowspan="1" data-role="columnsorter" data-index="13" data-title="Level B - Column M" data-field="LevelB-ColumnM"> <a class="k-link" href="#">Level B - Column M</a> </th> <th class="k-header" id="90b949ab-78f8-4778-984a-992374da34b1" role="columnheader" rowspan="1" data-role="columnsorter" data-index="14" data-title="Level B - Column N" data-field="LevelB-ColumnN"> <a class="k-link" href="#">Level B - Column N</a> </th> <th class="k-header" id="b9b62c5f-2e81-4463-aaa0-e7c1f473301a" role="columnheader" rowspan="1" data-role="columnsorter" data-index="15" data-title="Level B - Column O" data-field="LevelB-ColumnO"> <a class="k-link" href="#">Level B - Column O</a> </th> <th class="k-header" id="eecd1125-bb4b-4a68-94c8-ed6479338c2e" role="columnheader" rowspan="1" data-role="columnsorter" data-index="16" data-title="Level B - Column P" data-field="LevelB-ColumnP"> <a class="k-link" href="#">Level B - Column P</a> </th> <th class="k-header" id="554a07ba-5beb-4866-a1cb-fe799d9860b9" role="columnheader" rowspan="1" data-role="columnsorter" data-index="17" data-title="Level B - Column Q" data-field="LevelB-ColumnQ"> <a class="k-link" href="#">Level B - Column Q</a> </th> <th class="k-header" id="67faac62-176f-4a77-a7a6-5634b1bae5ca" role="columnheader" rowspan="1" data-role="columnsorter" data-index="18" data-title="Level B - Column R" data-field="LevelB-ColumnR"> <a class="k-link" href="#">Level B - Column R</a> </th> <th class="k-header" id="2d67383a-1088-4aff-b5f0-2f5bcb16a210" role="columnheader" rowspan="1" data-role="columnsorter" data-index="19" data-title="Level B - Column S" data-field="LevelB-ColumnS"> <a class="k-link" href="#">Level B - Column S</a> </th> <th class="k-header" id="6cc61b25-58d3-4604-9190-ce8fadcc5e85" role="columnheader" rowspan="1" data-role="columnsorter" data-index="20" data-title="Level B - Column T" data-field="LevelB-ColumnT"> <a class="k-link" href="#">Level B - Column T</a> </th> </tr> </thead> </table> </div> </div> <div class="k-grid-content"> <table class="k-selectable" role="treegrid" aria-multiselectable="true" data-role="selectable"> <colgroup> <col class="k-hierarchy-col"> <col style="width:30px"> <col style="width:650px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> <col style="width:100px"> </colgroup> <tbody role="rowgroup"> <tr class="k-master-row" role="row" data-uid="363cc750-6cee-4c7e-99c4-e99f38a16374"> <td class="k-hierarchy-cell"> <a tabindex="-1" class="k-icon k-plus" href="#"/> </td> <td role="gridcell"> <input class="checkbox niveauB" type="checkbox"> </td> <td role="gridcell">Level B - Column A (1)</td> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> <td class="red_bg" role="gridcell"/> </tr> </tbody> </table> </div> <div class="k-pager-wrap k-grid-pager k-widget k-floatwrap" data-role="pager"> <a tabindex="-1" title="Go to the first page" class="k-link k-pager-nav k-pager-first k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-seek-w">Go to the first page</span> </a><a tabindex="-1" title="Go to the previous page" class="k-link k-pager-nav k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-arrow-w">Go to the previous page</span> </a> <ul class="k-pager-numbers k-reset"> <li class="k-current-page"> <span class="k-link k-pager-nav">1</span> </li> <li> <span class="k-state-selected">1</span> </li> </ul><a tabindex="-1" title="Go to the next page" class="k-link k-pager-nav k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-arrow-e">Go to the next page</span> </a><a tabindex="-1" title="Go to the last page" class="k-link k-pager-nav k-pager-last k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-seek-e">Go to the last page</span> </a> <span class="k-pager-info k-label">1 - 1 of 1 items</span> </div> </div> </td> </tr> </tbody> </table> </div> <div class="k-pager-wrap k-grid-pager k-widget k-floatwrap" data-role="pager"> <a tabindex="-1" title="Go to the first page" class="k-link k-pager-nav k-pager-first k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-seek-w">Go to the first page</span> </a><a tabindex="-1" title="Go to the previous page" class="k-link k-pager-nav k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-arrow-w">Go to the previous page</span> </a> <ul class="k-pager-numbers k-reset"> <li class="k-current-page"> <span class="k-link k-pager-nav">1</span> </li> <li> <span class="k-state-selected">1</span> </li> </ul><a tabindex="-1" title="Go to the next page" class="k-link k-pager-nav k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-arrow-e">Go to the next page</span> </a><a tabindex="-1" title="Go to the last page" class="k-link k-pager-nav k-pager-last k-state-disabled" href="#" data-page="1"> <span class="k-icon k-i-seek-e">Go to the last page</span> </a> <span class="k-pager-sizes k-label"> <span tabindex="0" title="" class="k-widget k-dropdown k-header" role="listbox" aria-busy="false" aria-disabled="false" aria-expanded="false" aria-haspopup="true" aria-readonly="false" aria-activedescendant="b16c5762-0265-4765-a0b9-af55e4bd6b67" aria-owns="" unselectable="on"> <span class="k-dropdown-wrap k-state-default" unselectable="on"> <span class="k-input" unselectable="on">5</span> <span class="k-select" unselectable="on"> <span class="k-icon k-i-arrow-s" unselectable="on">select</span> </span> </span> <select style="display: none;" data-role="dropdownlist"> <option value="all">All</option> <option value="5">5</option> <option value="10">10</option> <option value="20">20</option> </select> </span>items per page</span><a title="Refresh" class="k-pager-refresh k-link" href="#"> <span class="k-icon k-i-refresh">Refresh</span> </a> <span class="k-pager-info k-label">1 - 2 of 2 items</span> </div> </div>
- Entreprise A - Niveau A
---- Entreprise A - Niveau B (1)
---- Entreprise A - Niveau B (2)
-------- Entreprise A - Niveau C (1)
-------- Entreprise A - Niveau C (2)
---- Entreprise A - Niveau B (3)
- Entreprise B - Niveau A
---- Entreprise B - Niveau B (1)
---- Entreprise B - Niveau B (2)
-------- Entreprise B - Niveau C (1)
-------- Entreprise B - Niveau C (2)
---- Entreprise B - Niveau B (3)
Chacune des lignes a une checkbox dans la première colonne. Celles du niveau A ont une classe CSS comme suit : class="checkbox niveauA", idem pour le niveau B : class="checkbox niveauB" et pour le niveau C : class="checkbox niveauC".
Quand l'utilisateur coche une checkbox du niveau A (il ne peut en sélectionner qu'une à la fois pour ce niveau), j'aimerai que les checkboxes du niveau B situé sous le niveau sélectionné soient automatiquement sélectionnées.
J'arrive à sélectionner toutes les checkboxes du niveau B, mais si je sélectionne "Entreprise A - Niveau A", cela va également me sélectionner les checkboxes du niveau B pour l'entreprise B :
Code Javascript : Sélectionner tout - Visualiser dans une fenêtre à part $(".checkbox.niveauB").prop('checked', true);
J'imagine qu'il faut juste trouver le sélecteur adéquat, mais je sèche complètement. Avez-vous une idée ?
Partager