comparison DataTables-1.9.4/extras/FixedColumns/row_grouping_height.html @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ac5f9272033b
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
5 <link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico">
6
7 <title>FixedColumns example</title>
8 <style type="text/css" title="currentStyle">
9 @import "../../media/css/demo_page.css";
10 @import "../../media/css/demo_table.css";
11 </style>
12 <script type="text/javascript" charset="utf-8" src="../../media/js/jquery.js"></script>
13 <script type="text/javascript" charset="utf-8" src="../../media/js/jquery.dataTables.js"></script>
14 <script type="text/javascript" charset="utf-8" src="media/js/FixedColumns.js"></script>
15 <script type="text/javascript" charset="utf-8">
16 $(document).ready( function () {
17 var oTable = $('#example').dataTable( {
18 "sScrollY": "300px",
19 "sScrollX": "100%",
20 "sScrollXInner": "150%",
21 "bScrollCollapse": true,
22 "bPaginate": false
23 } );
24
25 new FixedColumns( oTable, {
26 "iLeftWidth": 150,
27 "fnDrawCallback": function ( left, right ) {
28 var that = this, groupVal = null, matches = 0, heights = [], index = -1;
29
30 /* Get the heights of the cells and remove redundant ones */
31 $('tbody tr td', left.body).each( function ( i ) {
32 var currVal = this.innerHTML;
33
34 /* Reset values on new cell data. */
35 if (currVal != groupVal) {
36 groupVal = currVal;
37 index++;
38 heights[index] = 0;
39 matches = 0;
40 } else {
41 matches++;
42 }
43
44 heights[ index ] += $(this.parentNode).height();
45 if ( currVal == groupVal && matches > 0 ) {
46 this.parentNode.parentNode.removeChild(this.parentNode);
47 }
48 } );
49
50 /* Now set the height of the cells which remain, from the summed heights */
51 $('tbody tr td', left.body).each( function ( i ) {
52 that.fnSetRowHeight( this.parentNode, heights[i] );
53 } );
54 }
55 } );
56 } );
57 </script>
58 </head>
59 <body id="dt_example">
60 <div id="container">
61 <div class="full_width big">
62 FixedColumns example - row grouping using the fixed column
63 </div>
64
65 <h1>Preamble</h1>
66 <p>This example shows how it is possible to manipulate the DOM of the fixed column to create the effect of row grouping in the table (or more generally any manipulation you wish to make). When ordered by the first column it is possible to see the grouping in full effect - if you then change the ordering to one of the other columns the grouping is dynamically changed to combine like cells. It would be readily possible to extend this example to use two fixed columns and only 'group' rows in one of the columns, potentially achieving quite a powerful effect.</p>
67
68 <h1>Live example</h1>
69 <div id="demo">
70 <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
71 <thead>
72 <tr>
73 <th>Rendering engine</th>
74 <th>Browser</th>
75 <th>Platform(s)</th>
76 <th>Engine version</th>
77 <th>CSS grade</th>
78 </tr>
79 </thead>
80 <tbody>
81 <tr class="gradeX">
82 <td>Trident</td>
83 <td>Internet
84 Explorer 4.0</td>
85 <td>Win 95+</td>
86 <td class="center">4</td>
87 <td class="center">X</td>
88 </tr>
89 <tr class="gradeC">
90 <td>Trident</td>
91 <td>Internet
92 Explorer 5.0</td>
93 <td>Win 95+</td>
94 <td class="center">5</td>
95 <td class="center">C</td>
96 </tr>
97 <tr class="gradeA">
98 <td>Trident</td>
99 <td>Internet
100 Explorer 5.5</td>
101 <td>Win 95+</td>
102 <td class="center">5.5</td>
103 <td class="center">A</td>
104 </tr>
105 <tr class="gradeA">
106 <td>Trident</td>
107 <td>Internet
108 Explorer 6</td>
109 <td>Win 98+</td>
110 <td class="center">6</td>
111 <td class="center">A</td>
112 </tr>
113 <tr class="gradeA">
114 <td>Trident</td>
115 <td>Internet Explorer 7</td>
116 <td>Win XP SP2+</td>
117 <td class="center">7</td>
118 <td class="center">A</td>
119 </tr>
120 <tr class="gradeA">
121 <td>Trident</td>
122 <td>AOL browser (AOL desktop)</td>
123 <td>Win XP</td>
124 <td class="center">6</td>
125 <td class="center">A</td>
126 </tr>
127 <tr class="gradeA">
128 <td>Gecko</td>
129 <td>Firefox 1.0</td>
130 <td>Win 98+ / OSX.2+</td>
131 <td class="center">1.7</td>
132 <td class="center">A</td>
133 </tr>
134 <tr class="gradeA">
135 <td>Gecko</td>
136 <td>Firefox <br>1.5</td>
137 <td>Win 98+ / OSX.2+</td>
138 <td class="center">1.8</td>
139 <td class="center">A</td>
140 </tr>
141 <tr class="gradeA">
142 <td>Gecko</td>
143 <td>Firefox 2.0</td>
144 <td>Win 98+ / OSX.2+</td>
145 <td class="center">1.8</td>
146 <td class="center">A</td>
147 </tr>
148 <tr class="gradeA">
149 <td>Gecko</td>
150 <td>Firefox 3.0</td>
151 <td>Win 2k+ / OSX.3+</td>
152 <td class="center">1.9</td>
153 <td class="center">A</td>
154 </tr>
155 <tr class="gradeA">
156 <td>Gecko</td>
157 <td>Camino 1.0</td>
158 <td>OSX.2+</td>
159 <td class="center">1.8</td>
160 <td class="center">A</td>
161 </tr>
162 <tr class="gradeA">
163 <td>Gecko</td>
164 <td>Camino 1.5</td>
165 <td>OSX.3+</td>
166 <td class="center">1.8</td>
167 <td class="center">A</td>
168 </tr>
169 <tr class="gradeA">
170 <td>Gecko</td>
171 <td>Netscape 7.2</td>
172 <td>Win 95+ / Mac OS 8.6-9.2</td>
173 <td class="center">1.7</td>
174 <td class="center">A</td>
175 </tr>
176 <tr class="gradeA">
177 <td>Gecko</td>
178 <td>Netscape Browser 8</td>
179 <td>Win 98SE+</td>
180 <td class="center">1.7</td>
181 <td class="center">A</td>
182 </tr>
183 <tr class="gradeA">
184 <td>Gecko</td>
185 <td>Netscape Navigator 9</td>
186 <td>Win 98+ / OSX.2+</td>
187 <td class="center">1.8</td>
188 <td class="center">A</td>
189 </tr>
190 <tr class="gradeA">
191 <td>Gecko</td>
192 <td>Mozilla 1.0</td>
193 <td>Win 95+ / OSX.1+</td>
194 <td class="center">1</td>
195 <td class="center">A</td>
196 </tr>
197 <tr class="gradeA">
198 <td>Gecko</td>
199 <td>Mozilla 1.1</td>
200 <td>Win 95+ / OSX.1+</td>
201 <td class="center">1.1</td>
202 <td class="center">A</td>
203 </tr>
204 <tr class="gradeA">
205 <td>Gecko</td>
206 <td>Mozilla 1.2</td>
207 <td>Win 95+ / OSX.1+</td>
208 <td class="center">1.2</td>
209 <td class="center">A</td>
210 </tr>
211 <tr class="gradeA">
212 <td>Gecko</td>
213 <td>Mozilla 1.3</td>
214 <td>Win 95+ / OSX.1+</td>
215 <td class="center">1.3</td>
216 <td class="center">A</td>
217 </tr>
218 <tr class="gradeA">
219 <td>Gecko</td>
220 <td>Mozilla 1.4</td>
221 <td>Win 95+ / OSX.1+</td>
222 <td class="center">1.4</td>
223 <td class="center">A</td>
224 </tr>
225 <tr class="gradeA">
226 <td>Gecko</td>
227 <td>Mozilla 1.5</td>
228 <td>Win 95+ / OSX.1+</td>
229 <td class="center">1.5</td>
230 <td class="center">A</td>
231 </tr>
232 <tr class="gradeA">
233 <td>Gecko</td>
234 <td>Mozilla 1.6</td>
235 <td>Win 95+ / OSX.1+</td>
236 <td class="center">1.6</td>
237 <td class="center">A</td>
238 </tr>
239 <tr class="gradeA">
240 <td>Gecko</td>
241 <td>Mozilla 1.7</td>
242 <td>Win 98+ / OSX.1+</td>
243 <td class="center">1.7</td>
244 <td class="center">A</td>
245 </tr>
246 <tr class="gradeA">
247 <td>Gecko</td>
248 <td>Mozilla 1.8</td>
249 <td>Win 98+ / OSX.1+</td>
250 <td class="center">1.8</td>
251 <td class="center">A</td>
252 </tr>
253 <tr class="gradeA">
254 <td>Gecko</td>
255 <td>Seamonkey 1.1</td>
256 <td>Win 98+ / OSX.2+</td>
257 <td class="center">1.8</td>
258 <td class="center">A</td>
259 </tr>
260 <tr class="gradeA">
261 <td>Gecko</td>
262 <td>Epiphany 2.20</td>
263 <td>Gnome</td>
264 <td class="center">1.8</td>
265 <td class="center">A</td>
266 </tr>
267 <tr class="gradeA">
268 <td>Webkit</td>
269 <td>Safari 1.2</td>
270 <td>OSX.3</td>
271 <td class="center">125.5</td>
272 <td class="center">A</td>
273 </tr>
274 <tr class="gradeA">
275 <td>Webkit</td>
276 <td>Safari 1.3</td>
277 <td>OSX.3</td>
278 <td class="center">312.8</td>
279 <td class="center">A</td>
280 </tr>
281 <tr class="gradeA">
282 <td>Webkit</td>
283 <td>Safari 2.0</td>
284 <td>OSX.4+</td>
285 <td class="center">419.3</td>
286 <td class="center">A</td>
287 </tr>
288 <tr class="gradeA">
289 <td>Webkit</td>
290 <td>Safari 3.0</td>
291 <td>OSX.4+</td>
292 <td class="center">522.1</td>
293 <td class="center">A</td>
294 </tr>
295 <tr class="gradeA">
296 <td>Webkit</td>
297 <td>OmniWeb 5.5</td>
298 <td>OSX.4+</td>
299 <td class="center">420</td>
300 <td class="center">A</td>
301 </tr>
302 <tr class="gradeA">
303 <td>Webkit</td>
304 <td>iPod Touch / iPhone</td>
305 <td>iPod</td>
306 <td class="center">420.1</td>
307 <td class="center">A</td>
308 </tr>
309 <tr class="gradeA">
310 <td>Webkit</td>
311 <td>S60</td>
312 <td>S60</td>
313 <td class="center">413</td>
314 <td class="center">A</td>
315 </tr>
316 <tr class="gradeA">
317 <td>Presto</td>
318 <td>Opera 7.0</td>
319 <td>Win 95+ / OSX.1+</td>
320 <td class="center">-</td>
321 <td class="center">A</td>
322 </tr>
323 <tr class="gradeA">
324 <td>Presto</td>
325 <td>Opera 7.5</td>
326 <td>Win 95+ / OSX.2+</td>
327 <td class="center">-</td>
328 <td class="center">A</td>
329 </tr>
330 <tr class="gradeA">
331 <td>Presto</td>
332 <td>Opera 8.0</td>
333 <td>Win 95+ / OSX.2+</td>
334 <td class="center">-</td>
335 <td class="center">A</td>
336 </tr>
337 <tr class="gradeA">
338 <td>Presto</td>
339 <td>Opera 8.5</td>
340 <td>Win 95+ / OSX.2+</td>
341 <td class="center">-</td>
342 <td class="center">A</td>
343 </tr>
344 <tr class="gradeA">
345 <td>Presto</td>
346 <td>Opera 9.0</td>
347 <td>Win 95+ / OSX.3+</td>
348 <td class="center">-</td>
349 <td class="center">A</td>
350 </tr>
351 <tr class="gradeA">
352 <td>Presto</td>
353 <td>Opera 9.2</td>
354 <td>Win 88+ / OSX.3+</td>
355 <td class="center">-</td>
356 <td class="center">A</td>
357 </tr>
358 <tr class="gradeA">
359 <td>Presto</td>
360 <td>Opera 9.5</td>
361 <td>Win 88+ / OSX.3+</td>
362 <td class="center">-</td>
363 <td class="center">A</td>
364 </tr>
365 <tr class="gradeA">
366 <td>Presto</td>
367 <td>Opera for Wii</td>
368 <td>Wii</td>
369 <td class="center">-</td>
370 <td class="center">A</td>
371 </tr>
372 <tr class="gradeA">
373 <td>Presto</td>
374 <td>Nokia N800</td>
375 <td>N800</td>
376 <td class="center">-</td>
377 <td class="center">A</td>
378 </tr>
379 <tr class="gradeA">
380 <td>Presto</td>
381 <td>Nintendo DS browser</td>
382 <td>Nintendo DS</td>
383 <td class="center">8.5</td>
384 <td class="center">C/A</td>
385 </tr>
386 <tr class="gradeC">
387 <td>KHTML</td>
388 <td>Konqureror 3.1</td>
389 <td>KDE 3.1</td>
390 <td class="center">3.1</td>
391 <td class="center">C</td>
392 </tr>
393 <tr class="gradeA">
394 <td>KHTML</td>
395 <td>Konqureror 3.3</td>
396 <td>KDE 3.3</td>
397 <td class="center">3.3</td>
398 <td class="center">A</td>
399 </tr>
400 <tr class="gradeA">
401 <td>KHTML</td>
402 <td>Konqureror 3.5</td>
403 <td>KDE 3.5</td>
404 <td class="center">3.5</td>
405 <td class="center">A</td>
406 </tr>
407 <tr class="gradeX">
408 <td>Tasman</td>
409 <td>Internet Explorer 4.5</td>
410 <td>Mac OS 8-9</td>
411 <td class="center">-</td>
412 <td class="center">X</td>
413 </tr>
414 <tr class="gradeC">
415 <td>Tasman</td>
416 <td>Internet Explorer 5.1</td>
417 <td>Mac OS 7.6-9</td>
418 <td class="center">1</td>
419 <td class="center">C</td>
420 </tr>
421 <tr class="gradeC">
422 <td>Tasman</td>
423 <td>Internet Explorer 5.2</td>
424 <td>Mac OS 8-X</td>
425 <td class="center">1</td>
426 <td class="center">C</td>
427 </tr>
428 <tr class="gradeA">
429 <td>Misc</td>
430 <td>NetFront 3.1</td>
431 <td>Embedded devices</td>
432 <td class="center">-</td>
433 <td class="center">C</td>
434 </tr>
435 <tr class="gradeA">
436 <td>Misc</td>
437 <td>NetFront 3.4</td>
438 <td>Embedded devices</td>
439 <td class="center">-</td>
440 <td class="center">A</td>
441 </tr>
442 <tr class="gradeX">
443 <td>Misc</td>
444 <td>Dillo 0.8</td>
445 <td>Embedded devices</td>
446 <td class="center">-</td>
447 <td class="center">X</td>
448 </tr>
449 <tr class="gradeX">
450 <td>Misc</td>
451 <td>Links</td>
452 <td>Text only</td>
453 <td class="center">-</td>
454 <td class="center">X</td>
455 </tr>
456 <tr class="gradeX">
457 <td>Misc</td>
458 <td>Lynx</td>
459 <td>Text only</td>
460 <td class="center">-</td>
461 <td class="center">X</td>
462 </tr>
463 <tr class="gradeC">
464 <td>Misc</td>
465 <td>IE Mobile</td>
466 <td>Windows Mobile 6</td>
467 <td class="center">-</td>
468 <td class="center">C</td>
469 </tr>
470 <tr class="gradeC">
471 <td>Misc</td>
472 <td>PSP browser</td>
473 <td>PSP</td>
474 <td class="center">-</td>
475 <td class="center">C</td>
476 </tr>
477 <tr class="gradeU">
478 <td>Other browsers</td>
479 <td>All others</td>
480 <td>-</td>
481 <td class="center">-</td>
482 <td class="center">U</td>
483 </tr>
484 </tbody>
485 </table>
486 </div>
487 <div class="spacer"></div>
488
489
490 <h1>Initialisation code</h1>
491 <pre>$(document).ready( function () {
492 var oTable = $('#example').dataTable( {
493 "sScrollY": "300px",
494 "sScrollX": "100%",
495 "sScrollXInner": "150%",
496 "bScrollCollapse": true,
497 "bPaginate": false
498 } );
499
500 new FixedColumns( oTable, {
501 "iLeftWidth": 150,
502 "fnDrawCallback": function ( left, right ) {
503 var that = this, groupVal = null, matches = 0, heights = [], index = -1;
504
505 /* Get the heights of the cells and remove redundant ones */
506 $('tbody tr td', left.body).each( function ( i ) {
507 var currVal = this.innerHTML;
508
509 /* Reset values on new cell data. */
510 if (currVal != groupVal) {
511 groupVal = currVal;
512 index++;
513 heights[index] = 0;
514 matches = 0;
515 } else {
516 matches++;
517 }
518
519 heights[ index ] += $(this.parentNode).height();
520 if ( currVal == groupVal &amp;&amp; matches &gt; 0 ) {
521 this.parentNode.parentNode.removeChild(this.parentNode);
522 }
523 } );
524
525 /* Now set the height of the cells which remain, from the summed heights */
526 $('tbody tr td', left.body).each( function ( i ) {
527 that.fnSetRowHeight( this.parentNode, heights[ i ] );
528 } );
529 }
530 } );
531 } );</pre>
532
533
534 <h1>Documentation</h1>
535 <ul>
536 <li><a href="http://datatables.net/extras/fixedcolumns">Usage</a></li>
537 <li><a href="http://datatables.net/docs/FixedColumns">API / parameters</a></li>
538 </ul>
539
540 <h1>Basic examples</h1>
541 <ul>
542 <li><a href="index.html">Basic demo of FixedColumns with zero initialisation</a></li>
543 <li><a href="left_right_columns.html">Fix the left and right columns in place</a></li>
544 <li><a href="index_column.html">Index column attached to side of the table</a></li>
545 <li><a href="x_y_scrolling.html">Index column, but with Y scrolling and no pagination</a></li>
546 <li><a href="two_columns.html">Two columns fixed in place</a></li>
547 <li><a href="right_column.html">Fix the right column in place</a></li>
548 <li><a href="css_size.html">Speeding up row height matching with CSS</a></li>
549 <li><a href="themed.html">jQuery UI themed table with FixedColumns</a></li>
550 </ul>
551
552 <h1>Advanced examples</h1>
553 <ul>
554 <li><a href="rowspan.html">Using ROWSPAN with FixedColumns</a></li>
555 <li><a href="server-side-processing.html">Server-side processing with FixedColumns</a></li>
556 <li><a href="col_filter.html">Individual column filtering</a></li>
557 <li><a href="scale_fixed.html">Setting the fixed column width and resizing the table</a></li>
558 <li><a href="scale_relative.html">Setting the fixed column width with relative sizing</a></li>
559 <li><a href="row_grouping_height.html">Row grouping by grouping like rows in the fixed column</a></li>
560 <li><a href="row_grouping.html">Row grouping by inserting a grouping row</a></li>
561 <ul>
562
563
564 <div id="footer" style="text-align:center;">
565 <span style="font-size:10px;">
566 FixedColumns and DataTables &copy; Allan Jardine 2011.<br>
567 </span>
568 </div>
569 </div>
570 </body>
571 </html>