victor
victor

Reputation: 1293

DataTables JS / TableTools JS - exporting and printing

I am using dataTables (http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js) & tableTools (http://www.datatables.net/release-datatables/extensions/TableTools/js/dataTables.tableTools.js & http://www.datatables.net/release-datatables/extensions/TableTools/css/dataTables.tableTools.css) and displaying a table and want to print it. But am having problems with the same.

Here are my options

 $("#reportTableId").DataTable({
            "paging": false,
            "ordering": false,
            "info": false,
            "sDom": 'Tlrt',
            "iDisplayLength": 100,
            tableTools: {
                "sSwfPath": "../ed1/static/swf/copy_csv_xls_pdf.swf",
                "aButtons": [
                    {
                        "sExtends": "collection",
                        "sButtonText": "Save",
                        "aButtons": [
                            {
                                "sExtends": "xls",
                                "sTitle": $Name
                            },
                            {
                                "sExtends": "pdf",
                                "sTitle": $Name
                            }
                        ],
                        "mColumns": [0, 1, 2],
                        "sPdfOrientation": "landscape"
                    },
                    {
                        "sExtends": "print",
                        "mColumns": "visible"
                    }
                ]
            }
        });

My report html structure is in the following format

    <table id="reportTableId">
  <tr>
    <th class="tg-031e" colspan="2"></th>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e" colspan="2"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
</table>

css

   .tg-031ea {
        width: 15%;
    }
  1. When I try to export to Excel, I get only the 1st columns, don't get the second;
  2. In excel no cell colors are exported
  3. In PDF I get only 1 page output thought the report HTML is 13 pages. I have tried to include columns, but no success.

Any help would be much appreciated.

HTML output: HTML snapshot

PDF output: (only the heading column) pdf output

Upvotes: 1

Views: 1136

Answers (1)

Vivek
Vivek

Reputation: 1461

Hope this is not too late, from my previous experience, I have learnt that Datatables requires valud HTML table, so having a colspan in your table does not help.

Upvotes: 1

Related Questions