jQuery Datatables responsive example
HTML
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css">
<script src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>
<script src="//cdn.datatables.net/responsive/1.0.2/js/dataTables.responsive.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/responsive/1.0.2/css/dataTables.responsive.css">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Stuff</th>
<th>Stuff1</th>
<th>Stuff2</th>
</tr>
</thead>
<tbody></tbody>
</table>
JavaScript
var data = [
{
Name: "Smithsaldklsajdkalsjdklsajdlkjsalkjdaslkjdlsakjdasd",
Stuff: "aslkjdlksajd",
Stuff1:"aslkjdlksajd",
Stuff2:""
}
];
$(document).ready(function() {
$('#example').DataTable( {
responsive: true,
"bDeferRender": true,
data: data,
aoColumns: [
{"mDataProp":"Name"},
{"mDataProp":"Stuff"},
{"mDataProp":"Stuff1"},
{
"mDataProp":"Stuff2",
"sName": "Stuff2",
"mRender": function () {
$("body").append("<p>render called</p>");
return "<button>hello</button>";
}
}
],
"createdRow": function ( row, data, index ) {
$(row).data("dt-data",data);
}
});
$('#example tbody').on( 'click', 'td button', function () {
var parentRow = $(this).closest("tr.child").prev();
alert((parentRow.data("dt-data").Stuff));
} );
});