datatable

datatable

Girish KumarGirish Kumar Posts: 15Questions: 11Answers: 0

datatable have two headers i want print pdf second header not first header. I

Answers

  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    The PDF export can only export a single row in the header at the moment. It is should be the second (or bottom most) row in the header. The orderCellsTop parameter controls that.

    If that isn't working for you, please post a link to a test case.

    Allan

  • Girish KumarGirish Kumar Posts: 15Questions: 11Answers: 0

    not working

  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    As I mentioned, if it doesn't work for you, please post a link to a test case.

    Allan

  • Girish KumarGirish Kumar Posts: 15Questions: 11Answers: 0
    Total
    Columns
    Image Supplier Id Supplier Name Tin No Outstanding Amount Supplier Type Place Action
                                </div>
                            </div>
    
  • Girish KumarGirish Kumar Posts: 15Questions: 11Answers: 0

    $("#supplierListTable tbody").children('tr').remove();

            oTable = transactionTable.dataTable({
                "processing" : true,
                "serverSide" : true,
                "iDisplayLength" : 50,
                "paging" : false,
                "searching" : true,
                "bSort" : false,
                "sDom" : 'clear',
    
    
    
    
    
                "sDom" : 'Bfrtip',
    
            "buttons" : [
                    {
                        extend : 'excelHtml5',
                        extension : '.xls',
    
                        text : 'excel',
                        titileAttr : "EXCEL",
                        header : true,
    
                        exportOptions : {
                            columns : [ 2, 3, 4, 5, 7 ],
                            stripHtml : false
                        },
    
                    },
                    {
                        extend : 'pdfHtml5',
    
                        text : 'PDF',
                        titileAttr : "PDF",
                        download : 'open',
                        pageSize : 'A4',
                        extension : '.pdf',
                        header : true,
                        footer : true,
    
                        exportOptions : {
                            columns : [ 2, 3, 4, 5, 7],
                            stripHtml : false
                        },
                        customize : function(doc) {
                            //alert("fun");
                            // ----------right and center alignment of all
                            // columns in pdfs-----------
                            var rowCount = document.getElementById("supplierListTable").rows.length;
                            /*for (var i = 1; i < rowCount; i++) {
    
                                doc.content[1].table.body[i][3].alignment = 'right';
    
    
                            }
                            ;*/
    
                            var result = getCompanyDeatilsList();
                            var companyDetails = result.toString().split(",");
                            // -----------------to display name Receipt List in
                            // left side ------------------
                            doc.content.splice(1, 0, {
                                text : [ {
                                    text : 'Supplier List',
                                    italics : false,
                                    fontSize : 13,
    
                                } ],
                                margin : [ 0, 0, 0, 30 ],
                                alignment : 'left'
    
                            });
                            // --------------------to display company details in
                            // right side------------
                            doc.content.splice(0, 1,
                                    {
                                        text : [
                                                {
                                                    text : companyDetails[0]
                                                            + "\n",
                                                    bold : true,
                                                    fontSize : 18,
    
                                                },
                                                {
                                                    text : "Address: "
                                                            + companyDetails[2]
                                                            + ".\n"
                                                            + companyDetails[3]
                                                            + ".\n"
                                                            + companyDetails[4]
                                                            + ".\n"
                                                            + companyDetails[5]
                                                            + ".\n",
                                                    italics : true,
                                                    fontSize : 8,
                                                },
                                                {
                                                    text : "phone: "
                                                            + companyDetails[8]
                                                            + "\n",
                                                    italics : true,
                                                    fontSize : 9,
                                                } ],
                                        margin : [ 0, 0, 0, 0 ],
                                        alignment : 'right',
    
                                    });
    
                        },
                    } ],
    
    
                // ---------------footer callback function for calculate total
            // amount----------------
            "footerCallback" : function(row, data, start, end, display) {
                var api = this.api(), data;
    
                // Remove the formatting to get integer data for summation
                var intVal = function(i) {
    
                    if(i.toString().endsWith(" Dr")){
                        return  i.toString().substring(0, i.length);
                    }
    
                    else{
                        return  i.toString().substring(0, i.length);
                    }
    
    
    
                };
                // Total on OverAll Page
                total = api.column(5).data().reduce(function(a, b) {
    
                    return parseFloat(intVal(a)) + parseFloat(intVal(b));
                }, 0);
    
                // Total over this page
    
                pageTotal = api.column(5, {
                    page : 'current'
                }).data().reduce(function(a, b) {
                    return parseFloat(intVal(a)) + parseFloat(intVal(b));
                }, 0);
    
                // Update footer
    
                // $(api.column(7).footer()).html('$' + pageTotal + ' ( $' +
                // total + ' total)');
    
                $(api.column(5).footer()).html(' ' + pageTotal + ' ');
            },
    
    
    
    
    
    
                "ajax" : {
                    "url" : url,
                    "type" : "POST",
                    "dataType" : 'json',
                    "dataSrc" : "data",
                    "async" : false,
                    "data" : supplierAdvacedsearchfun,
                },
                columns : [{
                    "targets" : -1,
                    "data" : null,
                    "defaultContent" : '<span class="row-details row-details-close"></span>'
                }, {
                    "data" : "supplierImage"
                }, {
                    "data" : "supplierId"
                }, {
                    "data" : "supplierName"
                }, {
                    "data" : "tinnumber"
                }, {
                    "data" : "OSAmount"
                }, {
                    "data" : "supplierType"
                }, {
                    "data" : "place"
                }, {
                    "targets" : -1,
                    "data" : null,
                    "defaultContent" : "<Select><option>Action</option><option>View</option><option>Edit</option><option>Delete</option><option>Supplier Ledger</option><option>Supplier InterestCalculation</option><option>Supplier InterestDetail</option><option>History</option></select>"
                }],
                "dom" : "<'row'<'col-md-6 col-xs-12'l><'col-md-6 col-xs-12'f>r><'table-responsive't><'row'<'col-md-5 col-xs-12'i><'col-md-7 col-xs-12'p>>", // datatable layout without  horizobtal scroll
                "columnDefs" : [{
                    "orderable" : false,
                    "targets" : [0]
                }],
                "order" : [[1, 'asc']],
                "lengthMenu" : [[5, 15, 20, -1], [5, 15, 20, "All"] // change per page values here
                ],
                // set the initial value
                "pageLength" : 20
            });
    
  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    If you can't post a link to your page showing the issue, please use http://live.datatables.net , JSFiddle, CodePen, JSBin or a similar service to link to a working test case that shows the error so we can debug it.

    Allan

This discussion has been closed.