I need to export data from a dataTable to Excel and PDF but I have a problem. When wanting to add the Excel and PDF export buttons, the number of records selector disappears to show why that place happens to occupy the Excel and PDF buttons and I want the record number selector to be shown as well.
Libraries used
<link href="plugins/datatables/extensions/Responsive/css/responsive.bootstrap.min.css" rel="stylesheet"/>
<link href="plugins/datatables/dataTables.bootstrap.min.css" rel="stylesheet"/>
<link href="plugins/datatables/dataTables.bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css">
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>
Properties that the table has
<table id="mtable" class="table table-striped table-condensed table-bordered dt-responsive nowrap table-hover" cellspacing="0" width="100%">
DataTable script
<!-- Inicio DataTable -->
<script type="text/javascript">
$(document).ready(function() {
$('#myTable').DataTable({
"language":{
"lengthMenu":"Mostrar _MENU_ registros por página.",
"zeroRecords": "Lo sentimos. No se encontraron registros.",
"sInfo": "Mostrando: _START_ de _END_ - Total registros: _TOTAL_ ",
"infoEmpty": "No hay registros aún.",
"infoFiltered": "(filtrados de un total de _MAX_ registros)",
"search" : "Búsqueda",
"LoadingRecords": "Cargando ...",
"Processing": "Procesando...",
"SearchPlaceholder": "Comience a teclear...",
"paginate": {
"previous": "Anterior",
"next": "Siguiente",
}
}
});
} );
</script>
<!-- Fin DataTable -->
Excel buttons script, PDP, Print
<script type="text/javascript">
$(document).ready(function() {
$('#mtable').DataTable( {
dom: 'Bfrtip',
buttons: [
'excel', 'pdf', 'print'
]
} );
} );
</script>
What must be done so that the select also appears, allowing you to display the records you want. And also how do I do if I do not want to export all the columns? And how you can change the title that comes out when you export the files, because a title appears that I do not know where it comes from.