Два нижних колонтитула не печатаются в формате pdf и excel при нажатии на кнопку в jquery datatable - PullRequest
0 голосов
/ 11 июня 2018

Actaullay У меня есть кнопки для сохранения в формате pdf и excel. У меня есть два нижних колонтитула из json в виде Total и Percentage. Когда я нажимаю кнопку, тогда только Total нижний колонтитул появляется, но строка Percentage не появляется в pdf и excelфайлы. Мне нужно показать оба нижнего колонтитула, но это не идет

<table id="report46Table" class="display responsive nowrap" style="width: 100%">
                    <thead>
                        <tr>
                            <th>Disturbance</th>
                            <th>Zero</th>
                            <th>Minor</th>
                            <th>Medium</th>
                            <th>Major</th>
                            <th>Total</th>
                            <th>Occurance</th>
                        </tr>
                    </thead>
                    <tfoot>
                    <tr id="fTotal">
                        <th>Total</th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                        <tr id="fPercentage">
                            <th>Total</th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>

                    </tfoot>

                </table>

скрипт для загрузки данных:

<script>
    $(document).ready(function() {
        var report46Data = [];
        var report46Footer = null;
        var report46Table = $('#report46Table').DataTable({
            data : report46Data,
            dom: 'Bfrtip',
            buttons: [
                'copy',
                {
          extend: 'excel',
          footer: true,
        text : 'Export to Excel',

          messageTop: 'Records of forest disturbances in the forest',
              filename: function(){

                  return 'report46';
              },
                },

                {
        extend: 'pdfHtml5',
        footer: true,
        //orientation : 'landscape',
        pageSize: 'TABLOID',
        text : 'Export to Pdf',
        messageTop: 'Records of forest disturbances in the forest',
        title: '',
        filename: function(){

                return 'report46';
            },
                },

            ],
            ordering: false,
            "paging" :false,
            columns : [ {
                "data" : "disturbanceName"
            }, {
                "data" : "iZero"
            }, {
                "data" : "iMinor"
            }, {
                "data" : "iMedium"
            } ,{
                "data" : "iMajor"
            },{
                "data" : "total"
            },{
                "data" : "occurance"
            }],
            "footerCallback" : function(row, data, start, end, display) {
                var api = this.api();
                if (report46Footer) {
                    $($("#fTotal")[0].cells[0]).html(report46Footer[0].disturbance);
                    $($("#fTotal")[0].cells[1]).html(report46Footer[0].iZero);
                    $($("#fTotal")[0].cells[2]).html(report46Footer[0].iMinor);
                    $($("#fTotal")[0].cells[3]).html(report46Footer[0].iMedium);
                    $($("#fTotal")[0].cells[4]).html(report46Footer[0].iMajor);
                    $($("#fTotal")[0].cells[5]).html(report46Footer[0].total);
                    $($("#fTotal")[0].cells[6]).html("");

                    $($("#fPercentage")[0].cells[0]).html(report46Footer[1].disturbance);
                    $($("#fPercentage")[0].cells[1]).html(report46Footer[1].iZero);
                    $($("#fPercentage")[0].cells[2]).html(report46Footer[1].iMinor);
                    $($("#fPercentage")[0].cells[3]).html(report46Footer[1].iMedium);
                    $($("#fPercentage")[0].cells[4]).html(report46Footer[1].iMajor);
                    $($("#fPercentage")[0].cells[5]).html(report46Footer[1].total);
                    $($("#fPercentage")[0].cells[6]).html("");
                }
            }
        });

        $.ajax({
            url : A_PAGE_CONTEXT_PATH + "/api/report46/all",
            method : "GET",
            dataType : "json",
            success : function(response) {
                report46Data = response.dataList;
                report46Footer = response.footer;

                report46Table.rows.add(report46Data).draw();
            }

        });

    });
</script>

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...