ajax.reload() - Responsive plugin
ajax.reload() - Responsive plugin

Hello,
I am using datatables with the responsive plugin, and all functions well. Except for when I use ajax.reload()
to load different data into the table.
Because the data is different, so to are column sizes. However datatable's responsive plugin doesn't accommodate this. causing a horizontal scrollbar to appear under certain circumstances.
table = $('#active-issues').DataTable({
"scrollY": pixels,
"dom": '<"top"if>rt<"bottom"><"clear">',
"paging": false,
"responsive":true,
"bProcessing": true,
"ajax": {
"data": function(){
id = (id == 'none' ? '' : id);
customer_id = ($('.customer-selection').val() == 'all' ? '' : $('.customer-selection').val());
$('#active-issues').DataTable().ajax.url("api/issues/?dashboard_id=" + id + "&customer_id=" + customer_id);
},
"dataSrc": function (json) {
if(typeof json['status'] != "undefined") {
if (json['status'] == 'forbidden') {
$('#session-error-modal').modal('show');
}
}
return json;
}
},
columns: [
{ responsivePriority: 1 },
{ responsivePriority: 2 },
{ responsivePriority: 4 },
{ responsivePriority: 7 },
{ responsivePriority: 3 },
{ responsivePriority: 6 },
{ responsivePriority: 5 },
{ responsivePriority: 8 }
],
"order": [
[ 6, 'asc' ],
[ 0, 'asc' ],
[ 3, 'desc' ]
],
"columnDefs": [
{ "type": "alt-string", targets: 6 },
{ "type": "alt-string", targets: 7 }
],
language: {
"searchPlaceholder":"Zoeken",
"search":"",
"info":"_TOTAL_ problemen",
"infoEmpty": "0 problemen",
"infoFiltered":"(gefilterd vanaf _MAX_ problemen)"
}
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I found a solution, but I am not sure if it is the best:
table.ajax.reload(null, false).responsive.recalc().columns.adjust();
.Yes, - that's the best way. I feel that should probably be automatic and will look into adding that.
Thanks for posting back.
Allan