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 - Custom child row renderer</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">
16 <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.js"></script>
17 <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
18 <script type="text/javascript" language="javascript" src="../../js/dataTables.responsive.js"></script>
19 <script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
20 <script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
21 <script type="text/javascript" language="javascript" class="init">
25 $(document).ready(function() {
26 $('#example').DataTable( {
29 renderer: function ( api, rowIdx ) {
30 // Select hidden columns for the given row
31 var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
32 var header = $( api.column( cell.column ).header() );
39 api.cell( cell ).data()+
42 } ).toArray().join('');
45 $('<table/>').append( data ) :
58 <body class="dt-example">
59 <div class="container">
61 <h1>Responsive example <span>Custom child row renderer</span></h1>
64 <p>The child row's for a collapsed table in Responsive, by default, show a <code class="tag" title="HTML tag">ul/li</code> list of the data from the hidden
65 columns. The <a href="//datatables.net/extensions/responsive/reference/option/responsive.details.renderer"><code class="option" title=
66 "Responsive initialisation option">responsive.details.renderer<span>R</span></code></a> option provide the ability to create your own custom renderer. It is given
67 two parameters: the DataTables API instance for the table and the row index to use.</p>
69 <p>This example shows the <a href="//datatables.net/reference/api/cells()"><code class="api" title="DataTables API method">cells()<span>DT</span></code></a> method
70 being used to select the hidden columns and constructing a table of the data. You could refine the selector to select only certain columns, or show all columns,
74 <table id="example" class="display nowrap" cellspacing="0" width="100%">
93 <td>System Architect</td>
99 <td>t.nixon@datatables.net</td>
110 <td>g.winters@datatables.net</td>
115 <td>Junior Technical Author</td>
116 <td>San Francisco</td>
121 <td>a.cox@datatables.net</td>
126 <td>Senior Javascript Developer</td>
132 <td>c.kelly@datatables.net</td>
143 <td>a.satou@datatables.net</td>
148 <td>Integration Specialist</td>
154 <td>b.williamson@datatables.net</td>
159 <td>Sales Assistant</td>
160 <td>San Francisco</td>
165 <td>h.chandler@datatables.net</td>
170 <td>Integration Specialist</td>
176 <td>r.davidson@datatables.net</td>
181 <td>Javascript Developer</td>
182 <td>San Francisco</td>
187 <td>c.hurst@datatables.net</td>
192 <td>Software Engineer</td>
198 <td>s.frost@datatables.net</td>
203 <td>Office Manager</td>
209 <td>j.gaines@datatables.net</td>
214 <td>Support Lead</td>
220 <td>q.flynn@datatables.net</td>
225 <td>Regional Director</td>
226 <td>San Francisco</td>
231 <td>c.marshall@datatables.net</td>
236 <td>Senior Marketing Designer</td>
242 <td>h.kennedy@datatables.net</td>
247 <td>Regional Director</td>
253 <td>t.fitzpatrick@datatables.net</td>
258 <td>Marketing Designer</td>
264 <td>m.silva@datatables.net</td>
269 <td>Chief Financial Officer (CFO)</td>
275 <td>p.byrd@datatables.net</td>
280 <td>Systems Administrator</td>
286 <td>g.little@datatables.net</td>
291 <td>Software Engineer</td>
297 <td>b.greer@datatables.net</td>
302 <td>Personnel Lead</td>
308 <td>d.rios@datatables.net</td>
313 <td>Development Lead</td>
319 <td>j.caldwell@datatables.net</td>
324 <td>Chief Marketing Officer (CMO)</td>
330 <td>y.berry@datatables.net</td>
335 <td>Pre-Sales Support</td>
341 <td>c.vance@datatables.net</td>
346 <td>Sales Assistant</td>
352 <td>d.wilder@datatables.net</td>
357 <td>Chief Executive Officer (CEO)</td>
363 <td>a.ramos@datatables.net</td>
374 <td>g.joyce@datatables.net</td>
379 <td>Regional Director</td>
385 <td>j.chang@datatables.net</td>
390 <td>Software Engineer</td>
391 <td>San Francisco</td>
396 <td>b.wagner@datatables.net</td>
401 <td>Chief Operating Officer (COO)</td>
402 <td>San Francisco</td>
407 <td>f.green@datatables.net</td>
412 <td>Regional Marketing</td>
418 <td>s.itou@datatables.net</td>
423 <td>Integration Specialist</td>
429 <td>m.house@datatables.net</td>
440 <td>s.burks@datatables.net</td>
445 <td>Technical Author</td>
451 <td>p.bartlett@datatables.net</td>
457 <td>San Francisco</td>
462 <td>g.cortez@datatables.net</td>
467 <td>Post-Sales support</td>
473 <td>m.mccray@datatables.net</td>
478 <td>Marketing Designer</td>
479 <td>San Francisco</td>
484 <td>u.butler@datatables.net</td>
489 <td>Office Manager</td>
490 <td>San Francisco</td>
495 <td>h.hatfield@datatables.net</td>
501 <td>San Francisco</td>
506 <td>h.fuentes@datatables.net</td>
511 <td>Financial Controller</td>
512 <td>San Francisco</td>
517 <td>v.harrell@datatables.net</td>
522 <td>Office Manager</td>
528 <td>t.mooney@datatables.net</td>
539 <td>j.bradshaw@datatables.net</td>
544 <td>Support Engineer</td>
550 <td>o.liang@datatables.net</td>
555 <td>Software Engineer</td>
561 <td>b.nash@datatables.net</td>
566 <td>Support Engineer</td>
572 <td>s.yamamoto@datatables.net</td>
583 <td>t.walton@datatables.net</td>
588 <td>Support Engineer</td>
589 <td>San Francisco</td>
594 <td>f.camacho@datatables.net</td>
599 <td>Data Coordinator</td>
605 <td>s.baldwin@datatables.net</td>
610 <td>Software Engineer</td>
616 <td>z.frank@datatables.net</td>
621 <td>Software Engineer</td>
622 <td>San Francisco</td>
627 <td>z.serrano@datatables.net</td>
632 <td>Junior Javascript Developer</td>
638 <td>j.acosta@datatables.net</td>
643 <td>Sales Assistant</td>
649 <td>c.stevens@datatables.net</td>
654 <td>Regional Director</td>
660 <td>h.butler@datatables.net</td>
665 <td>Systems Administrator</td>
671 <td>l.greer@datatables.net</td>
677 <td>San Francisco</td>
682 <td>j.alexander@datatables.net</td>
687 <td>Regional Director</td>
693 <td>s.decker@datatables.net</td>
698 <td>Javascript Developer</td>
704 <td>m.bruce@datatables.net</td>
709 <td>Customer Support</td>
715 <td>d.snider@datatables.net</td>
721 <li class="active">Javascript</li>
725 <li>Server-side script</li>
730 <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
731 $('#example').DataTable( {
734 renderer: function ( api, rowIdx ) {
735 // Select hidden columns for the given row
736 var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
737 var header = $( api.column( cell.column ).header() );
744 api.cell( cell ).data()+
747 } ).toArray().join('');
750 $('<table/>').append( data ) :
758 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
761 <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
762 <li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
763 <li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li>
768 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
773 <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
774 additional CSS used is shown below:</p><code class="multiline language-css"></code>
777 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
780 <li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
781 <li><a href="../../css/dataTables.responsive.css">../../css/dataTables.responsive.css</a></li>
786 <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
791 <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
792 processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
793 documentation</a>.</p>
801 <div class="gradient"></div>
804 <h2>Other examples</h2>
807 <div class="toc-group">
808 <h3><a href="../initialisation/index.html">Basic initialisation</a></h3>
810 <li><a href="../initialisation/className.html">Class name</a></li>
811 <li><a href="../initialisation/option.html">Configuration option</a></li>
812 <li><a href="../initialisation/new.html">`new` constructor</a></li>
813 <li><a href="../initialisation/ajax.html">Ajax data</a></li>
814 <li><a href="../initialisation/default.html">Default initialisation</a></li>
818 <div class="toc-group">
819 <h3><a href="../styling/index.html">Styling</a></h3>
821 <li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
822 <li><a href="../styling/foundation.html">Foundation styling</a></li>
823 <li><a href="../styling/scrolling.html">Vertical scrolling</a></li>
824 <li><a href="../styling/compact.html">Compact styling</a></li>
828 <div class="toc-group">
829 <h3><a href="../display-control/index.html">Display control</a></h3>
831 <li><a href="../display-control/auto.html">Automatic column hiding</a></li>
832 <li><a href="../display-control/classes.html">Class control</a></li>
833 <li><a href="../display-control/init-classes.html">Assigned class control</a></li>
834 <li><a href="../display-control/fixedHeader.html">With FixedHeader</a></li>
835 <li><a href="../display-control/complexHeader.html">Complex headers (rowspan / colspan)</a></li>
839 <div class="toc-group">
840 <h3><a href="./index.html">Child rows</a></h3>
841 <ul class="toc active">
842 <li><a href="./disable-child-rows.html">Disable child rows</a></li>
843 <li><a href="./column-control.html">Column controlled child rows</a></li>
844 <li><a href="./right-column.html">Column control - right</a></li>
845 <li><a href="./whole-row-control.html">Whole row child row control</a></li>
846 <li class="active"><a href="./custom-renderer.html">Custom child row renderer</a></li>
851 <div class="epilogue">
852 <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
853 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>
854 which extend the capabilities of DataTables.</p>
856 <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
857 DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>