首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在angularJS-datatable中从dtOptions访问表

如何在angularJS-datatable中从dtOptions访问表
EN

Stack Overflow用户
提问于 2017-11-13 04:36:27
回答 1查看 616关注 0票数 0

我正在尝试有一个csv下载按钮,需要从表中排除几个列。

我找到了一个exportOptions,它定义了应该导出哪些列。此选项来自jQuery数据包,table.column()方法可能用于选择列。

现在我需要选择某些列,但我无法找到如何使用角数据的方法。

有人知道解决办法吗?

代码语言:javascript
复制
    <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>

我用棱角的方式渲染桌子。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-14 12:14:07

角方向与纯jQuery DataTable没有区别。并且您不需要访问exportOptions中的表实例。您需要返回一个列选择器;下面是一些示例(不确切地知道您想要做什么):

代码语言:javascript
复制
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
} 

等。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47257126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档