1

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.

2
  • which data table jquery version are you using? Commented Nov 30, 2020 at 9:04
  • @MohsinMarui DataTables-1.10.21 Commented Nov 30, 2020 at 9:08

1 Answer 1

1

You can use the page.len() API call to dynamically change the page length.

$("#showAll").on("click", function () {
   $( '#' + tableId + '').dataTable().api().page.len( -1 ).draw();
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.