I'm using the Datatables responsive extension on a datatable with ajax sourced server-side data. Initialisation is like this:
var oTable = $('#sales-report').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": $("#rooturl").val() + '/Reporting/Reports/PopulateDatatable',
"data": function ( d ) {
return $.extend( {}, d, {
"date_start_filter": $('#FilterDateStart').val(),
etc...
});
}
},
'columns': [
{
'data': 1
},
etc...
]
});
The table looks like this, the responsive class is the initialiser:
<table class="table responsive table-bordered table-striped table-highlight nowrap " id="sales-report" width="100%" >
<thead>
<tr>
<th>Date</th>
<th>SKU</th>
etc....
</tr>
</thead>
<tbody></tbody>
</table>
When the page loads, there is no data in the table. The user then chooses filtering options and hits search which calls draw().
Assuming data is returned from the search, the datatable works fine, but the responsive 'collapsing' feature is not enabled. If the page is then refreshed without changing anything else, then the collapsing works.
I've tried initialising the table differently but the results are still the same. I'm sure this has something to do with the fact that the data is ajax sourced, but I'm now stuck. Any ideas?