Necesito exportar los datos de un dataTable a Excel y PDF pero me surge un Problema. Al querer agregar los botones de exportar excel y PDF desaparece el selector de número de registros para mostrar porque ese lugar lo pasa a ocupar los botenes Excel y PDF y quiero que también se muestre el selector de número de registros para mostrar.
Librerías utilizadas
<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>
Propiedades que tiene la tabla
<table id="mtable" class="table table-striped table-condensed table-bordered dt-responsive nowrap table-hover" cellspacing="0" width="100%">
Script del dataTable
<!-- 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 -->
Script de los botones excel, PDP, Print
<script type="text/javascript"> $ (document).ready(function() { $ ('#mtable').DataTable( { dom: 'Bfrtip', buttons: [ 'excel', 'pdf', 'print' ] } ); } ); </script>
Qué se debe hacer para que también aparezca el select que permite mostrar los registros que uno desee. Y también como hago si no quiero exportar todas las columnas?