Javascript 使用导出工具时显示条目下拉菜单消失

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32629949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 13:59:29  来源:igfitidea点击:

Show entries dropdown disappear when using export tools

javascriptjquerydatatables

提问by Almis

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

提琴手

回答by davidkonrad

You just lack the lflag in dom. lfor "length changing input control".

你只是缺少l的标志doml用于“长度改变输入控制”。

dom: 'lBfrtip'

will make the dropdown to reappear.

将使下拉菜单重新出现。

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

更新小提琴 -> http://jsfiddle.net/p33x5L3t/1/
dom文档 -> https://datatables.net/reference/option/dom

回答by The Voyager

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:

在按钮内添加“pageLength”,如下所示:

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

回答by Ashvin patidar

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"
         }
      });       
   });