如何在整页pdf中显示jquery数据表数据,以便覆盖整个页面?

时间:2018-06-10 02:33:28

标签: javascript jquery datatable datatables

实际上我正在使用jquery数据表,我已经制作了pdf下载按钮来保存datatable的内容。当我点击下载按钮时,内容被下载,但只有25%的pdf页面充满了数据。我希望数据能够覆盖整个页面的pdf页面。

  <script>
            $(document)
                    .ready(
                            function() {
                                var report31Data = \[\];
                                var orderData=\[\];
                                var report31Footer = null;
                                var report31Table = $('#report31Table')
                                        .DataTable(
                                                {
                                                    data : report31Data,
                                                    dom : 'Bfrtip',
                                                    buttons : \[
                                                            'copy',
                                                            {
                                                                extend : 'excel',
                                                                text : 'Export to Excel',

                                                                messageTop : 'Number of stems according to crown class',


                                                                filename : function() {

                                                                    return 'report31';
                                                                },
                                                            },

                                                            {
                                                                extend : 'pdf',
                                                                text : 'Export to Pdf',
                                                                messageTop : 'Number of stems according to crown class',

                                                                title : '',
                                                                filename : function() {

                                                                    return 'report31';
                                                                },
                                                            },


                                                    ordering: false,
                                                    paging: false,
                                                    columns : \[ {
                                                        "data" : "treeStatus"
                                                    }, {
                                                        "data" : "crownClassName"
                                                    }, {
                                                        "data" : "volPerHa"
                                                    } \],
                                                    "footerCallback" : function(row,
                                                            data, start, end, display) {
                                                        var api = this.api();
                                                        if (report31Footer) {
                                                            $(api.column(0).footer())
                                                                    .html(
                                                                            report31Footer.treeStatus);
                                                            $(api.column(1).footer())
                                                                    .html(
                                                                            report31Footer.crownClassName);
                                                            $(api.column(2).footer())
                                                                    .html(
                                                                            report31Footer.noOfSteamsPerHa);


                                                        }
                                                    }
                                                });

                                $.ajax({
                                    url : A_PAGE_CONTEXT_PATH + "/api/report31/all",
                                    method : "GET",
                                    dataType : "json",
                                    success : function(response) {
                                         var list = response.dataList.sort(function(a,b){
                                             return parseInt(a.order)-parseInt(b.order);
                                         });

                                        report31Data = list;
                                        report31Table.rows.add(report31Data).draw();
                                    }

                                });

                            });
        </script>

The pdf i get saved is] 1

0 个答案:

没有答案