我有一个数据表导出选项pdf excel,但是我有一些隐藏的列,我不想在导出中看到它们,这是我的代码
//Buttons examples
var table = $('#datatable-buttons').DataTable({
lengthChange: false,
buttons: ['copy', 'excel', 'pdf'],
retrieve: true
});
table.buttons().container()
.appendTo('#datatable-buttons_wrapper .col-md-6:eq(0)');
// Key Tables
$('#key-table').DataTable({
keys: true
});我尝试添加可见选项,但不起作用,请帮助
发布于 2021-07-29 06:20:46
最简单的方法是使用带有columns选项的exportOptions。
您可以为此提供一个列索引号数组-例如:
var colsToExport = [1, 2, 3]; // the first column has an index of 0
var table = $('#example').DataTable( {
dom: 'Brftip',
buttons: [
{
extend: 'pdf',
text: 'To PDF',
exportOptions: {
columns: colsToExport
}
},
{
extend: 'excel',
text: 'To Excel',
exportOptions: {
columns: colsToExport
}
}
]
} );如果您需要比简单的数组列表更复杂的东西,那么除了定义数组之外,还有各种替代方法-有关完整的详细信息,请参阅column-selector。
除了columns之外,还可以在here中找到导出选项的完整列表。
https://stackoverflow.com/questions/68567103
复制相似问题