Skip to content

Instantly share code, notes, and snippets.

@ozknozsrt
Created March 2, 2018 13:37
Show Gist options
  • Save ozknozsrt/b08be2de8b42844840060d6534b97679 to your computer and use it in GitHub Desktop.
Save ozknozsrt/b08be2de8b42844840060d6534b97679 to your computer and use it in GitHub Desktop.
dataTable child rows detail info without ajax
<tr data-child-name="test1" data-child-value="10">
<td>ParentRow</td>
<td>No. 1</td>
</tr>
In the click handler (line 50 from the example):
<script>
// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
if (row.child.isShown()) {
// This row is already open - close it
row.child( format( tr.data('child-name'), tr.data('child-value') ) ).hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format( tr.data('child-name'), tr.data('child-value') ) ).show();
tr.addClass('shown');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment