Server side processing error - Responsive and button error

Server side processing error - Responsive and button error

GonzaloOrtelladoGonzaloOrtellado Posts: 1Questions: 0Answers: 0

Hi, i've been workin with datatables and i think its great. But with the new release i just couldnt make it work the way i need it to work. The following code works great with static data, but when i use ajax to get new data, the table is not longer responsive and the buttons disappear.

This is the working code (static data):

PHP


Rendering engine Browser Platform(s) Engine version CSS grade
Trident Internet Explorer 4.0 Win 95+ 4 X
Rendering engine Browser Platform(s) Engine version CSS grade

Javascript


var example1 = $("#example1").DataTable({
responsive: true,
buttons: ['excelHtml5',
{
extend: 'pdfHtml5',
title: "*",
download: 'open'
},
{
extend: 'print',
autoPrint: true,
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
var medias = win.document.querySelectorAll('[media="screen"]');
for (var i = 0; i < medias.length; i++) { medias.item(i).media = "all" };
}
}
]
});
example1.buttons().container().appendTo($('.col-sm-6:eq(0)', example1.table().container()));

Not Working Code (Ajax called data):


var example1 = $("#example1").DataTable({
responsive: true,
buttons: ['excelHtml5',
{
extend: 'pdfHtml5',
title: "*",
download: 'open'
},
{
extend: 'print',
autoPrint: true,
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
var medias = win.document.querySelectorAll('[media="screen"]');
for (var i = 0; i < medias.length; i++) { medias.item(i).media = "all" };
}
}
],
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php"
});
example1.buttons().container().appendTo($('.col-sm-6:eq(0)', example1.table().container()));

I checked that the data and the php file sends the data correctly

Any ideas?

This discussion has been closed.