Remove table head from every pages.

Remove table head from every pages.

Sam190Sam190 Posts: 1Questions: 1Answers: 0

I'm new to using datatables. I want to hide the table head from displaying in every pages in print view. I only want to display the table head on first page. By the way I'm using bootstrap.

Here's my code:

        $('#example1').DataTable({
            "pagingType": "full_numbers",
            "sDom": "ti",
            dom: 'Bfrtip',
            bSortCellsTop: true,
            columnDefs: [
                {
                    className: "dt-center", 
                    targets: "_all"
                }
            ],

            buttons: [
                {
                    extend: 'print',
                    footer: false,
                    text: '<i class="fa fa-print"></i> Print',
                    exportOptions: {
                        format: {
                            body: function ( data, row, column, node ) {
                                return column === 3 ?
                                    data.replace( /<br>/, String.fromCharCode(10)) :
                                    data;
                            }
                        }
                    },
                    className: 'btn btn-primary add_emp',
                    customize: function ( doc ) {
                        $(doc.document.body).find('h1').css('font-size', '12pt');
                        $(doc.document.body).find('h1').css('text-align', 'center'); 
                        $(doc.document.body).find( 'table' ).addClass( 'compact' ).css( 'font-size', 'inherit' );

                    },
                    orientation: 'landscape'
                }
            ]
        });

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    You would need to tweak that doc in the customize() function - either by removing those headers by hand, or trying something like this SO thread,

    Colin

Sign In or Register to comment.