5 <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
6 <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
8 <title>Responsive example - Complex headers (rowspan / colspan)</title>
9 <link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
10 <link rel="stylesheet" type="text/css" href="../../css/dataTables.responsive.css">
11 <link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
12 <link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
13 <style type="text/css" class="init">
25 text-overflow: ellipsis;
30 <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.js"></script>
31 <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
32 <script type="text/javascript" language="javascript" src="../../js/dataTables.responsive.js"></script>
33 <script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
34 <script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
35 <script type="text/javascript" language="javascript" class="init">
39 $(document).ready(function() {
40 // jQuery update a column title from the demo table to contain a long description
41 // You would not need to do this in your own code.
42 $('#example thead tr:eq(0) th:eq(2)').html("This is a really long column title!");
44 // Wrap the colspan'ing header cells with a span so they can be positioned
45 // absolutely - filling the available space, and no more.
46 $('#example thead th[colspan]').wrapInner( '<span/>' ).append( ' ' );
48 // Standard initialisation
49 $('#example').DataTable( {
60 <body class="dt-example">
61 <div class="container">
63 <h1>Responsive example <span>Complex headers (rowspan / colspan)</span></h1>
66 <p>This example shows how Responsive can be used with <em>complex headers</em> (i.e. headers that contain <code>colspan</code> attributes for one or more cells).
67 As Responsive will removed columns one at a time the cell with the <code>colspan</code> attribute can end up forcing the width of a column, disrupting the flow.
68 Rather than removing all columns under the <code>colspan</code> cell, we want to reduce the amount of text that is visible in that cell. This example shows how
69 that can be achieved thought a little bit of jQuery and CSS.</p>
71 <p>We use jQuery to find the header cells which have a <code>colspan</code> attribute and wrap their contents in a <code class="tag" title="HTML tag">span</code>
72 tag. That <code class="tag" title="HTML tag">span</code> is then set to <code>position: absolute;</code> using <code>text-overflow: ellipsis</code>. The result is
73 that the text of the <code>colspan</code> cell will reduce automatically to fit the available area based on the contents of the column cells below it.</p>
75 <p>This functionality is not currently built into Responsive. It likely will be for v1.1.</p>
78 <table id="example" class="display nowrap" cellspacing="0" width="100%">
81 <th rowspan="2">Name</th>
82 <th colspan="2">HR Information</th>
83 <th colspan="3">Contact</th>
108 <td>System Architect</td>
112 <td>t.nixon@datatables.net</td>
115 <td>Garrett Winters</td>
120 <td>g.winters@datatables.net</td>
124 <td>Junior Technical Author</td>
126 <td>San Francisco</td>
128 <td>a.cox@datatables.net</td>
131 <td>Cedric Kelly</td>
132 <td>Senior Javascript Developer</td>
136 <td>c.kelly@datatables.net</td>
144 <td>a.satou@datatables.net</td>
147 <td>Brielle Williamson</td>
148 <td>Integration Specialist</td>
152 <td>b.williamson@datatables.net</td>
155 <td>Herrod Chandler</td>
156 <td>Sales Assistant</td>
158 <td>San Francisco</td>
160 <td>h.chandler@datatables.net</td>
163 <td>Rhona Davidson</td>
164 <td>Integration Specialist</td>
168 <td>r.davidson@datatables.net</td>
171 <td>Colleen Hurst</td>
172 <td>Javascript Developer</td>
174 <td>San Francisco</td>
176 <td>c.hurst@datatables.net</td>
180 <td>Software Engineer</td>
184 <td>s.frost@datatables.net</td>
188 <td>Office Manager</td>
192 <td>j.gaines@datatables.net</td>
196 <td>Support Lead</td>
200 <td>q.flynn@datatables.net</td>
203 <td>Charde Marshall</td>
204 <td>Regional Director</td>
206 <td>San Francisco</td>
208 <td>c.marshall@datatables.net</td>
211 <td>Haley Kennedy</td>
212 <td>Senior Marketing Designer</td>
216 <td>h.kennedy@datatables.net</td>
219 <td>Tatyana Fitzpatrick</td>
220 <td>Regional Director</td>
224 <td>t.fitzpatrick@datatables.net</td>
227 <td>Michael Silva</td>
228 <td>Marketing Designer</td>
232 <td>m.silva@datatables.net</td>
236 <td>Chief Financial Officer (CFO)</td>
240 <td>p.byrd@datatables.net</td>
243 <td>Gloria Little</td>
244 <td>Systems Administrator</td>
248 <td>g.little@datatables.net</td>
251 <td>Bradley Greer</td>
252 <td>Software Engineer</td>
256 <td>b.greer@datatables.net</td>
260 <td>Personnel Lead</td>
264 <td>d.rios@datatables.net</td>
267 <td>Jenette Caldwell</td>
268 <td>Development Lead</td>
272 <td>j.caldwell@datatables.net</td>
276 <td>Chief Marketing Officer (CMO)</td>
280 <td>y.berry@datatables.net</td>
283 <td>Caesar Vance</td>
284 <td>Pre-Sales Support</td>
288 <td>c.vance@datatables.net</td>
291 <td>Doris Wilder</td>
292 <td>Sales Assistant</td>
296 <td>d.wilder@datatables.net</td>
299 <td>Angelica Ramos</td>
300 <td>Chief Executive Officer (CEO)</td>
304 <td>a.ramos@datatables.net</td>
312 <td>g.joyce@datatables.net</td>
315 <td>Jennifer Chang</td>
316 <td>Regional Director</td>
320 <td>j.chang@datatables.net</td>
323 <td>Brenden Wagner</td>
324 <td>Software Engineer</td>
326 <td>San Francisco</td>
328 <td>b.wagner@datatables.net</td>
332 <td>Chief Operating Officer (COO)</td>
334 <td>San Francisco</td>
336 <td>f.green@datatables.net</td>
340 <td>Regional Marketing</td>
344 <td>s.itou@datatables.net</td>
347 <td>Michelle House</td>
348 <td>Integration Specialist</td>
352 <td>m.house@datatables.net</td>
360 <td>s.burks@datatables.net</td>
363 <td>Prescott Bartlett</td>
364 <td>Technical Author</td>
368 <td>p.bartlett@datatables.net</td>
371 <td>Gavin Cortez</td>
374 <td>San Francisco</td>
376 <td>g.cortez@datatables.net</td>
379 <td>Martena Mccray</td>
380 <td>Post-Sales support</td>
384 <td>m.mccray@datatables.net</td>
387 <td>Unity Butler</td>
388 <td>Marketing Designer</td>
390 <td>San Francisco</td>
392 <td>u.butler@datatables.net</td>
395 <td>Howard Hatfield</td>
396 <td>Office Manager</td>
398 <td>San Francisco</td>
400 <td>h.hatfield@datatables.net</td>
403 <td>Hope Fuentes</td>
406 <td>San Francisco</td>
408 <td>h.fuentes@datatables.net</td>
411 <td>Vivian Harrell</td>
412 <td>Financial Controller</td>
414 <td>San Francisco</td>
416 <td>v.harrell@datatables.net</td>
419 <td>Timothy Mooney</td>
420 <td>Office Manager</td>
424 <td>t.mooney@datatables.net</td>
427 <td>Jackson Bradshaw</td>
432 <td>j.bradshaw@datatables.net</td>
435 <td>Olivia Liang</td>
436 <td>Support Engineer</td>
440 <td>o.liang@datatables.net</td>
444 <td>Software Engineer</td>
448 <td>b.nash@datatables.net</td>
451 <td>Sakura Yamamoto</td>
452 <td>Support Engineer</td>
456 <td>s.yamamoto@datatables.net</td>
464 <td>t.walton@datatables.net</td>
467 <td>Finn Camacho</td>
468 <td>Support Engineer</td>
470 <td>San Francisco</td>
472 <td>f.camacho@datatables.net</td>
475 <td>Serge Baldwin</td>
476 <td>Data Coordinator</td>
480 <td>s.baldwin@datatables.net</td>
483 <td>Zenaida Frank</td>
484 <td>Software Engineer</td>
488 <td>z.frank@datatables.net</td>
491 <td>Zorita Serrano</td>
492 <td>Software Engineer</td>
494 <td>San Francisco</td>
496 <td>z.serrano@datatables.net</td>
499 <td>Jennifer Acosta</td>
500 <td>Junior Javascript Developer</td>
504 <td>j.acosta@datatables.net</td>
507 <td>Cara Stevens</td>
508 <td>Sales Assistant</td>
512 <td>c.stevens@datatables.net</td>
515 <td>Hermione Butler</td>
516 <td>Regional Director</td>
520 <td>h.butler@datatables.net</td>
524 <td>Systems Administrator</td>
528 <td>l.greer@datatables.net</td>
531 <td>Jonas Alexander</td>
534 <td>San Francisco</td>
536 <td>j.alexander@datatables.net</td>
540 <td>Regional Director</td>
544 <td>s.decker@datatables.net</td>
547 <td>Michael Bruce</td>
548 <td>Javascript Developer</td>
552 <td>m.bruce@datatables.net</td>
555 <td>Donna Snider</td>
556 <td>Customer Support</td>
560 <td>d.snider@datatables.net</td>
566 <li class="active">Javascript</li>
570 <li>Server-side script</li>
575 <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
576 // jQuery update a column title from the demo table to contain a long description
577 // You would not need to do this in your own code.
578 $('#example thead tr:eq(0) th:eq(2)').html("This is a really long column title!");
580 // Wrap the colspan'ing header cells with a span so they can be positioned
581 // absolutely - filling the available space, and no more.
582 $('#example thead th[colspan]').wrapInner( '<span/>' ).append( '&nbsp;' );
584 // Standard initialisation
585 $('#example').DataTable( {
591 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
594 <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
595 <li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
596 <li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li>
601 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
606 <p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
607 additional CSS used is shown below:</p><code class="multiline language-css">th {
617 text-overflow: ellipsis;
622 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
625 <li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
626 <li><a href="../../css/dataTables.responsive.css">../../css/dataTables.responsive.css</a></li>
631 <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
636 <p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
637 processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
638 documentation</a>.</p>
646 <div class="gradient"></div>
649 <h2>Other examples</h2>
652 <div class="toc-group">
653 <h3><a href="../initialisation/index.html">Basic initialisation</a></h3>
655 <li><a href="../initialisation/className.html">Class name</a></li>
656 <li><a href="../initialisation/option.html">Configuration option</a></li>
657 <li><a href="../initialisation/new.html">`new` constructor</a></li>
658 <li><a href="../initialisation/ajax.html">Ajax data</a></li>
659 <li><a href="../initialisation/default.html">Default initialisation</a></li>
663 <div class="toc-group">
664 <h3><a href="../styling/index.html">Styling</a></h3>
666 <li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
667 <li><a href="../styling/foundation.html">Foundation styling</a></li>
668 <li><a href="../styling/scrolling.html">Vertical scrolling</a></li>
669 <li><a href="../styling/compact.html">Compact styling</a></li>
673 <div class="toc-group">
674 <h3><a href="./index.html">Display control</a></h3>
675 <ul class="toc active">
676 <li><a href="./auto.html">Automatic column hiding</a></li>
677 <li><a href="./classes.html">Class control</a></li>
678 <li><a href="./init-classes.html">Assigned class control</a></li>
679 <li><a href="./fixedHeader.html">With FixedHeader</a></li>
680 <li class="active"><a href="./complexHeader.html">Complex headers (rowspan / colspan)</a></li>
684 <div class="toc-group">
685 <h3><a href="../child-rows/index.html">Child rows</a></h3>
687 <li><a href="../child-rows/disable-child-rows.html">Disable child rows</a></li>
688 <li><a href="../child-rows/column-control.html">Column controlled child rows</a></li>
689 <li><a href="../child-rows/right-column.html">Column control - right</a></li>
690 <li><a href="../child-rows/whole-row-control.html">Whole row child row control</a></li>
691 <li><a href="../child-rows/custom-renderer.html">Custom child row renderer</a></li>
696 <div class="epilogue">
697 <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
698 Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and <a href="http://www.datatables.net/plug-ins">plug-ins</a>
699 which extend the capabilities of DataTables.</p>
701 <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
702 DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>