我正在设置一个可重新排序的表, 使用 { mat-table , MatTableDataSource } 但是当我拖动一列时,我希望它的位置具有不透明的白色背景颜色。 这可以做到吗? 示例图片链接:/image/LSIdY.jpg
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8" cdkDropListGroup *ngIf="Loaded">
<ng-container [matColumnDef]="column" *ngFor="let column of columnsWithoutSelect; let i = index" >
<th mat-header-cell *matHeaderCellDef mat-sort-header cdkDropList
cdkDropListLockAxis="x"
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropListDropped($event, i)"
cdkDrag
(cdkDragStarted)="dragStarted($event, i)"
[cdkDragData]="{name: column, columIndex: i}"> {{headsColumns[column]}} </th>
<td mat-cell *matCellDef="let element" [ngClass]="stateRow ? 'td-min-1': 'td-min-2'" > {{element[column]}} </td>
</ng-container>
</table>
最佳答案
您可以简单地将自定义样式添加到拖动列表中。
<th mat-header-cell class="drop-list
CSS
.drop-list{
width: 100%;
border: solid 1px #ccc;
min-height: 60px;
display: block;
background: white;
border-radius: 4px;
overflow: hidden;
}
This are just examples styles you have to adjust them to fit your needs.
有关更多示例,请参阅 here
还有cdkDropList
和cdkDrag
不应位于同一元素上。
设置cdkDropList
给您<th>
和cdkDrag
给你<td>
关于javascript - 如何修复拖动时数据表中标题的设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58707276/