View all details of a column with responsive?
View all details of a column with responsive?
btb12
Posts: 6Questions: 3Answers: 0
I am using the ellipsis render to limit the amount of characters in a column of my table.
Is it possible to use the responsive extension to display the entire column's info when it is expanded?
Thank you for any help you can provide.
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.18/r-2.2.2/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.18/r-2.2.2/datatables.min.js"></script>
<script>
$(document).ready(function() {
$('#example').DataTable( {
columnDefs: [ {
targets: 1,
render: function ( data, type, row ) {
return data.length > 15 ?
data.substr( 0, 15 ) +'…' :
data;
}
}],
responsive: true
} );
} );
</script>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th class="none">Branch</th>
</tr>
</thead>
<tbody>
<tr>
<td>Test 1</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td>
<td>ABC</td>
</tr>
</tbody>
</table>
This discussion has been closed.
Answers
Hi @btb12 ,
Yep, you can have a custom render that can show anything - see this example.
Cheers,
Colin