【发布时间】:2015-11-30 21:21:49
【问题描述】:
requestsTable = $('#reportTable').dataTable({
sDom: 'T<"clear">lfrtip',
iDisplayLength: 10,
aLengthMenu: [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
tableTools: {
sRowSelect: "os",
sSwfPath: "TableTools/swf/copy_csv_xls_pdf.swf",
aButtons: [
{
sExtends: "collection",
sButtonText: "Save",
sButtonClass: "save-collection",
aButtons: [ 'copy', 'xls' ]
},
'print'
]
}
});
requestsTable.fnSetColumnVis( 22, false );
requestsTable.fnSetColumnVis( 23, false );
导出时,我得到了第 22 和 23 列的数据,但没有得到它们的列标题...
html部分代码是:
<table id="reportTable" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr style="font-size: smaller;">
<th>Request Id</th>
<th>Request<br />Type</th>
<th>...</th>
...
...
so on.....
</tr>
</thead>
<tbody>
<tr>
<td>105</td>
<td>evt</td>
...
...
so on......
</tr>
</tbody>
</table>
希望将所有数据与隐藏列一起导出...
【问题讨论】:
-
你的 html 是什么样子的?顺便说一句,你能格式化你的代码吗?
-
html 部分代码:
查看声明 请求ID 请求
类型... ...依此类推.....105 evt ... 以此类推...... -
表有 32 列,我在导出的 csv 中获取所有 32 列数据,但不是隐藏列的列名
-
尝试用
aButtons: [{ "sExtends": "copy", "mColumns": "visible", "bSelectedOnly": true }, { "sExtends": "xls", "mColumns": "visible", "bSelectedOnly": true },]替换aButtons: [ 'copy', 'xls' ] -
感谢您的回复。如果我使“mcolumns”:可见,表是否只导出可见列。我想要导出文件中的所有列数据和标题,甚至隐藏列。
标签: jquery datatables tabletools