jquerydatatablespagination

jQuery Datatables Remove Paging on button click


Is it possible to change the properties of a Data-table defined during initialising based on the actions of user? I do not want to destroy() the table and create or initialise again. Is there some other method? I want to remove paging from the datatable, when a user clicks on a button

$('#example').dataTable( {
    "paging": true
} );

<button id="stopPaging"> Stop Paging<button>

I want to change to "paging":false on the click of the button. Thanks in advance.


Solution

  • You call disable and hide the pagination by adding below click event to your js file.

    $( "#stopPaging" ).click(function() {
      $('#dataTables_paginate').find('a').each(function(e){
            $(this).off('click');
            $(this).parent().css("display","none")
        })
    });
    

    Hope this will help.

    Cheers