我需要在现有列的上方再添加一个colspan = 4的列,它必须具有粘性,就像另一个标题列一样。代码在这里:
<div class="example-container mat-elevation-z8">
<div class="wrapper">
<table mat-table [dataSource]="dataSource">
<!-- Position Column -->
<ng-container matColumnDef="all" sticky>
<th mat-header-cell *matHeaderCellDef> Все </th>
<td mat-cell *matCellDef="let element"> {{element.all}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="done">
<th mat-header-cell *matHeaderCellDef> Выполнено </th>
<td mat-cell *matCellDef="let element"> {{element.done}} </td>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="ctrl">
<th mat-header-cell *matHeaderCellDef> На контроле </th>
<td mat-cell *matCellDef="let element"> {{element.ctrl}} </td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="rjct">
<th mat-header-cell *matHeaderCellDef> Отклонено </th>
<td mat-cell *matCellDef="let element"> {{element.rjct}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</div>
我该如何实现?我尝试添加纯HTML,但没有成功,就像添加另一个角度表元素一样。
答案 0 :(得分:0)
为该列添加新的double
,然后向float
添加ng-container
属性,如下所示:
colspan
这将确保该行跨越4列。
然后,添加th
定义,如下所示:
<ng-container matColumnDef="grouped">
<th mat-header-cell *matHeaderCellDef colspan="4"> Grouped </th>
</ng-container>