数据表页脚未包含在数据表打印导出选项中



我正在使用带有DataTable的CodeIgniter和Ajax请求来获取数据并尝试使用DataTable Print Export选项打印数据。但是页脚没有出现在印刷品中。

如何将页脚包含在DataTable的打印中?

这是我的代码:

function data_table_report(dateselected){
    $("#dataTables-report").dataTable().fnDestroy();
    table =  $('#dataTables-report').DataTable({
        "ajax": {
        "url": "<?php echo site_url('patients_report/dataTable_report/')?>"+dateselected,
        "type": "POST",
        },
        responsive: true,
        bInfo: false,
        dom: 'Bfrtip',
        buttons: [{ extend: 'print',
            exportOptions: {
                columns: ':visible'
                 }
        },
        'colvis'],
        columnDefs: [ { 
            targets: -1,
            visible: false} 
       ]
   });
}

添加此:

buttons: [{ extend: 'print', footer: true }]

添加页脚属性,如下所示

buttons: [{ extend: 'print',
            footer: true,
            exportOptions: {
                columns: ':visible'
                 }
         }]

尝试以下:

"fnInitComplete": function (oSettings, json) {          
    myfooter = this.find('tfoot')[0].innerHTML;
    new $.fn.dataTable.Buttons( this, {
    buttons: [          
         {
            extend: 'print',
            exportOptions : {
                columns: ':not(.notForPrint)'
            },
            customize: function ( win ) {
                $(win.document.body)
                    .css( 'font-size','10pt') 
                    .css( 'font-family','arial'); 
                $(win.document.body).find( 'table' )
                    .addClass( 'compact' )
                    .css( 'font-size', 'inherit' );
                $(win.document.body).find('tfoot')[0].innerHTML = myfooter ;
                win.print();
                setTimeout(win.close(),500);
            }
        }
    ]
    });
    this.DataTable().buttons().container().insertBefore( '#example_filter');  

},

最新更新