This example shows the responsive.details.display
option being used with the modal
option, which, when used with the jQuery UI
integration for Responsive, will use jQuery UI's native modal display.
The built-in modal
display option should be executed as a function with optional parameters passed in to control the behaviour of the modal
display. In the case of jQuery UI it has a header
option (which is a function that should return the title for the modal) and a modal
option which is an object of configuration parameters that will be passed to the jQuery UI modal.
Additionally, the responsive.details.renderer
option is used here to display the full data for the row, rather than just the hidden
columns, which is the default behaviour.
The Javascript shown below is used to initialise the table shown in this example:
$(document).ready(function() {
$('#example').DataTable( {
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.modal( {
header: function ( row ) {
var data = row.data();
return 'Details for '+data[0]+' '+data[1];
}
} ),
renderer: function ( api, rowIdx, columns ) {
var data = $.map( columns, function ( col, i ) {
return '<tr>'+
'<td>'+col.title+':'+'</td> '+
'<td>'+col.data+'</td>'+
'</tr>';
} ).join('');
return $('<table width="100%"/>').append( data );
}
}
}
} );
} );
In addition to the above code, the following Javascript library files are loaded for use in this example:
The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:
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 additional CSS used is shown below:
The following CSS library files are loaded for use in this example to provide the styling of the table:
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 loaded.
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 processing scripts can be written in any language, using the protocol described in the DataTables documentation.