JSFiddle - React, Tailwind, and code Playground
by MaartenB
HTML
<link rel="stylesheet" href="https://nightly.datatables.net/css/jquery.dataTables.min.css">
<script src="https://nightly.datatables.net/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://nightly.datatables.net/responsive/css/responsive.dataTables.min.css">
<script src="https://nightly.datatables.net/responsive/js/dataTables.responsive.min.js"></script>
<div id="child-expand-all">Click here to expand the row...</div>
<br /><br />
<table id="example" class="display nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th class="none">Extn.</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Tiger</td>
<td>Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
<td>5421</td>
</tr>
</tbody>
</table>
JavaScript
var table = $('#example').DataTable( {
responsive: {
details: {
type: 'column'
}
},
columnDefs: [ {
className: 'control',
orderable: false,
targets: 0
}],
order: [ 1, 'asc' ]
} );
$('#child-expand-all').on('click', function() {
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
this.child.show();
$( this.node() ).addClass( 'parent' );
alert('You clicked to expand the row.');
});
});