laravelbuttondatatablepagination

paging:false not working with "Bfrtip" in datatable on laravel and how do I know data table version?


I face some jQuery problem on my laravel 7 version. When I add Excel, PDF, print button and pagination at a time. It didn't work. But I need both at a time. When I add bfrtip on jQuery, it works but when I add paging:false it doesn't work. And without bfrtip adding paging work properly. What can I do now? And how do I know data table version?

<table cellspacing="0" class="responsive table table-striped table-bordered" id="datatable_account">
    <thead>
        <tr>
            <th width="5%">No.</th>
            <th width="30%" data="1">Account Code</th>
            <th width="60%" data="2">Account Head</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>No.</th>
            <th>Account Code</th>
            <th>Account Head</th>
        </tr>
    </tfoot>
    <tbody>
        <?php
        $sn = 1;
        ?>
    @if(count($accounts)>0)  
    @foreach($accounts as $account)
        <tr class="accounts">
            <td>{{$sn++}}</td>
            <td>{{$account->account_code}}</td>
            <td>{{$account->account_head}}</td>
        </tr>
    @endforeach
    @else    
        <tr>
            <td colspan="5" class="emptyMessage">Empty</td>
        </tr>
    @endif
    </tbody>
</table>
<script>
$(document).ready(function () {
    $('#datatable_account').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'excel', 'pdf', 'print'
        ]
    });           
    $('#datatable_account').DataTable({
        paging: false,
    });
});
</script> 

Solution

  • Add data-paging=false on table tag. And It works as paging:false as well as bfrtip also work.

    <table cellspacing="0" class="responsive table table-striped table-bordered" id="datatable_account" data-paging='false'>
                                    <thead>
                                        <tr>
                                            <th width="5%">No.</th>
                                            <th width="30%" data="1">Account Code</th>
                                            <th width="60%" data="2">Account Head</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                            <th>No.</th>
                                            <th>Account Code</th>
                                            <th>Account Head</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>
                                        <?php
                                        $sn = 1;
                                        ?>
                                    @if(count($accounts)>0)  
                                    @foreach($accounts as $account)
                                        <tr class="accounts">
                                            <td>{{$sn++}}</td>
                                            <td>{{$account->account_code}}</td>
                                            <td>{{$account->account_head}}</td>
                                        </tr>
                                    @endforeach
                                    @else    
                                        <tr>
                                            <td colspan="5" class="emptyMessage">Empty</td>
                                        </tr>
                                    @endif
                                    </tbody>
                                </table>