I have the following js fiddle https://jsfiddle.net/jek1uobr/ .Though I have added the print button it is not displayed in the datatable.
$(function () {$('#example').DataTable( {
orderCellsTop: true,
dom: 'Bfrtip',
buttons: [
'print'
],
"columnDefs": [
{ "width": "25%", "targets": [ 1 ] }
],
"dom" : '<"top"fl<"clear">>rt<"bottom"ip<"clear">>',
initComplete: function () {
this.api().columns([1,2,3,4,5]).every(function () {
var column = this;
var select = $('<select style="width:130px; font-size: 13px; padding: 2px 1px 2px 1px; background: #fff; border: 1px solid #ccc; border-radius: 6px;position: relative; "><option value="">(All)</option></select>')
.appendTo($(column.header()))
.appendTo( $("#example thead tr:eq(1) th").eq(column.index()).empty())
.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search(val ? '^' + val + '$' : '', true, false)
.draw();
});
column.data().unique().sort().each(function (d, j) {
select.append('<option value="' + d + '">' + d + '</option>')
} );
} );
}
} );});
You just need to add,
For more information you can see the like below, https://datatables.net/reference/option/dom
Your updated code should look like this,