首页 > 解决方案 > angular-6-datatable 多选行

问题描述

我在我的角度项目中使用 angular-6-datatable 并使用 wnt 来选择多行。如何在“angular-6-datatable”上实现多行选择。过去 3-4 小时我一直在谷歌上搜索,但没有收到任何帖子。

标签: angularangular6angular-datatables

解决方案


数据表在角度上被贬低了,现在新模块是p-table,放开链接,它将带你到文档。

https://www.primefaces.org/primeng-6.1.6/#/table/export

如果您只想通过数据表浏览,请关闭链接。

https://www.primefaces.org/primeng-6.1.6/#/datatable/export

下面的代码被说服选择要导出的行,您可以按照您需要的格式修改下面的代码。

<p-table #dt [columns]="cols" [value]="cars" selectionMode="multiple" [(selection)]="selectedCars">
    <ng-template pTemplate="caption">
        <div class="ui-helper-clearfix">
            <button type="button" pButton icon="fa fa-file-o" iconPos="left" label="All Data" (click)="dt.exportCSV()" style="float:left"></button>
            <button type="button" pButton icon="fa fa-file" iconPos="left" label="Selection Only" (click)="dt.exportCSV({selectionOnly:true})" style="float:right"></button>
        </div>
    </ng-template>
    <ng-template pTemplate="header" let-columns>
        <tr>
            <th *ngFor="let col of columns">
                {{col.header}}
            </th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowData let-columns="columns">
        <tr [pSelectableRow]="rowData">
            <td *ngFor="let col of columns">
                {{rowData[col.field]}}
            </td>
        </tr>
    </ng-template>
</p-table>


推荐阅读