【发布时间】:2016-02-11 19:15:30
【问题描述】:
我使用带有导出按钮的 angular-datatable 插件。
此处示例:http://l-lin.github.io/angular-datatables/#/withButtons
vm.dtOptions = DTOptionsBuilder.fromSource('data.json')
.withDOM('frtip')
.withPaginationType('full_numbers')
// Active Buttons extension
.withButtons([
'columnsToggle',
'colvis',
'copy',
'print',
'excel',
{
text: 'Some button',
key: '1',
action: function (e, dt, node, config) {
alert('Button activated');
}
}
]);
我的问题是,当我尝试导出时,显示隐藏的列。
我试图找到仅导出可见列的解决方案,我在这里找到了解决方案 https://datatables.net/forums/discussion/3210/tabletools-how-to-hide-columns-when-exporting-copying
$('#list').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "swf/copy_cvs_xls_pdf.swf", // setting path for swf file. Displays export buttons
"aButtons": [{
"sExtends": "copy",
"mColumns": [0, 1, 2, 3, 4, 5] // Export settings for Copy to Clipboard
}, {
"sExtends": "csv",
"mColumns": [0, 1, 2, 3, 4, 5] // Export settings for CSV file
}, {
"sExtends": "xls",
"mColumns": [0, 1, 2, 3, 4, 5] // Export settings for Excel file
}, {
"sExtends": "pdf",
"mColumns": [0, 1, 2, 3, 4, 5], // Export settings for PDF file
"sPdfOrientation": "landscape"
}],
},
- 如何将此选项添加到 angular-datatable 插件,用于选择导出的列?
- 如何更改导出文件的文件名(如 excel、pdf)?
【问题讨论】:
标签: javascript jquery angularjs datatable datatables