我正在使用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)并显示一个表并想要打印它。但我遇到了同样的问题。
以下是我的选择
$("#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"
}
]
}
});
我的报告html结构采用以下格式
<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%;
}
非常感谢任何帮助。
HTML输出:
PDF输出:(仅标题栏)
答案 0 :(得分:1)
希望这还不算太晚,根据我之前的经验,我已经了解到Datatables需要使用valud HTML表,因此在表中使用colspan无济于事。