Show entries dropdown disappear when using export

2020-02-09 05:50发布

问题:

Show entries dropdown disappear when using export tools

$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'Bfrtip', // if you remove this line you will see the show entries dropdown
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    } );
});

jsfiddle

回答1:

You just lack the l flag in dom. l for "length changing input control".

dom: 'lBfrtip'

will make the dropdown to reappear.

updated fiddle -> http://jsfiddle.net/p33x5L3t/1/
dom documentation -> https://datatables.net/reference/option/dom



回答2:

I know it is too long, but if some one still facing this issue, then please do the following, it is an alternate answer.

Add 'pageLength' inside buttons as follows:

$('#example').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'pageLength','copy', 'csv', 'excel', 'print'
    ]
} );


回答3:

This works for me:

$(document).ready(function(){   
      dataTable = $('#myDataTable').DataTable({
         "processing":true,
         "serverSide":true,
          dom:'lBfrtip',
          buttons: ['excel', 'csv', 'pdf', 'copy'],
         "lengthMenu": [50,100,500,1000,2000,5000,10000,50000,100000],
         "order":[],
         "sScrollX": "100%",
         "scrollCollapse": true,
         "ajax":{
            url:"FetchAllAjax.php",
            type:"POST"
         }
      });       
   });