Show entries dropdown disappear when using export

2020-02-09 06:01发布

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

3条回答
三岁会撩人
2楼-- · 2020-02-09 06:16

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

查看更多
可以哭但决不认输i
3楼-- · 2020-02-09 06:25

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"
         }
      });       
   });
查看更多
霸刀☆藐视天下
4楼-- · 2020-02-09 06:32

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'
    ]
} );
查看更多
登录 后发表回答