简体   繁体   English

如何使用 Datatable jQuery 显示表上的所有行

[英]How to show all rows on table with using Datatable jQuery

I work with datatable library, and i want to show all rows on tapping on the separate button.我使用数据表库,我想在点击单独的按钮时显示所有行。

I try to use few methods but its not working.我尝试使用几种方法,但它不起作用。

My code:我的代码:

if (val != '') {
    $('#' + tableId + '').DataTable({
        destroy: true,
        lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]], // this is not working, showing default values
        searchPanes: {
            layout: 'columns-' + length + ''
        },
        columnDefs: [{
            searchPanes: {
                show: true
            },
            targets: '_all'
        }],

        dom: 'Pfrtip'
    });
    $('.dtsp-searchPanes').children().each(function (i, obj) {
        if (!val.includes(i)) $(this).hide();
        else $(this).show();
    });
} else {
    $('#' + tableId + '').DataTable({
        destroy: true
    });
}

$("#showAll").on("click", function () {
   //here i need func
});

I try to use this parameter:我尝试使用这个参数:

'iDisplayLength': 100

But this is not working for me, plus I need to have this possibility not like parameter but like separate function.但这对我不起作用,而且我需要这种可能性不像参数,而是像单独的 function。

You can use the page.len() API call to dynamically change the page length.您可以使用page.len() API 调用来动态更改页面长度。

$("#showAll").on("click", function () {
   $( '#' + tableId + '').dataTable().api().page.len( -1 ).draw();
});

Hey try increasing the pageLength嘿尝试增加pageLength

$('#example').DataTable( {
  "pageLength": 50
} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM