Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82127

Footer not printing in PDF or Excel

$
0
0
Hello,

PDF/Excel export not printing Updated Footer based on fnFooterCallback. The Data in PDF is from page load.

Thanks for the help.

oTable = $('#dtTable').dataTable({
        "sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
        "oTableTools": {
            "aButtons": [
            {
                "sButtonClass" : "btn-primary",
                "sExtends": "copy",
                'mColumns':'visible',
                "fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
                    return '"' + sValue.replace(/<br>|<BR>/g, "\n") + '"';
                }
            },
            {
                "sButtonClass" : "btn-primary",
                "sExtends": "print",
                'mColumns':'visible',
            },
            {
                "sButtonClass" : "btn-primary",
                "sExtends": "pdf",
                "sTitle": "Report for First Name Last Name",
                "sPdfOrientation": "landscape",
                'mColumns':'visible',
            },
            {
                "sButtonClass" : "btn-primary",
                "sExtends": "xls",
                "sTitle": "Report for First Name Last Name",
                "fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
                    return '"' + sValue.replace(/<br>|<BR>/g, "\n") + '"';
                }
            }
            ]
        },
        //"sScrollY": "200px",
        //"bPaginate": false,
        "iDisplayLength" : 20,
        "bProcessing": true,
        "bAutoWidth": false,
        "bServerSide": false,
        "sAjaxSource": dataUrl,

        "fnServerData": function(sSource, aoData, fnCallback) {
            $.ajax({
                "dataType": 'json',
                "type": "Get",
                "url": sSource,
                "data": aoData,
                "success": fnCallback
            });
        },
        "fnRowCallback": function(nRow, aData, iDisplayIndex) {
            var oTable = $('#dtTable').dataTable();
            var col;
            //find the status
            for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
                if (oTable.fnSettings().aoColumns[i].sTitle == "Status") {
                    col = i;
                    break;
                }
            }
            if (aData[col] == "Disapproved") {
                $('td:eq(' + col + ')', nRow).parent().addClass("error");
            }
            return nRow;
        },
        "fnFooterCallback": function(nRow, aaData, iStart, iEnd, aiDisplay) {
            var oTable = $('#dtTable').dataTable();
            var col;
            //find the total col
            for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
                if (oTable.fnSettings().aoColumns[i].sTitle == "Amount") {
                    col = i;
                    break;
                }
            }
            var iTotal = 0;
            //add the total up
            for (var i = iStart; i < iEnd; i++) {
                iTotal += Number(aaData[aiDisplay[i]][col].substring(1,aaData[aiDisplay[i]][col].length).replace(/[^0-9\.]+/g,""));
            }
            if (!isNaN(iTotal)) {
                nCells = $('.TfootDataTable');
                //'<th style="text-align:right;" colspan="'+col+'">Total</th><th style="text-align:left;" colspan="5">$ ' +iTotal+ '</th>';
                nCells.html('<th style="text-align:right;" colspan="' + col + '">Total</th><th style="text-align:left;" colspan="50">' + FormatToCurrency(iTotal) + '</th>');
            }
        }
    });


Viewing all articles
Browse latest Browse all 82127

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>