我正在尝试有一个csv下载按钮,需要从表中排除几个列。
我找到了一个exportOptions,它定义了应该导出哪些列。此选项来自jQuery数据包,table.column()方法可能用于选择列。
现在我需要选择某些列,但我无法找到如何使用角数据的方法。
有人知道解决办法吗?
<table dt-options="dtOptions" dt-column-defs="dtColumnDef">
<thead>
<tr>
<th>hoo</th>
<th>hoo</th>
</tr>
</thead>
<tbody>
<tr>
<td>hoo</td>
<td>hoo</td>
</tr>
</tbody>
</table>
<script>
// here is inside my controller
$scope.dtOptions = DTOptionsBuilder
.newOptions()
.withDOM('tB')
.withButtons([
{
text: 'download csv',
extend: 'csv',
exportOptions:
{
// columns: I neet to select certain columns here
// wiht method like "table.columns(0)" mentioned in jQuery datatables document
// but I don't know how in angular-datatables
}
}]);
</script>我用棱角的方式渲染桌子。
发布于 2017-11-14 12:14:07
角方向与纯jQuery DataTable没有区别。并且您不需要访问exportOptions中的表实例。您需要返回一个列选择器;下面是一些示例(不确切地知道您想要做什么):
exportOptions: {
columns: [0,4,5] //some columns by index
}
exportOptions: {
columns: 'th' //any column
}
exportOptions: {
columns: ['th:eq(1)', 'th:eq(5)'] //same as numbered array
}
exportOptions: {
columns: 'th:not(:first)' //exclude the first column
}
exportOptions: {
columns: 'th:not(.no-export)' //exclude columns with class no-export
} 等。
https://stackoverflow.com/questions/47257126
复制相似问题