admin管理员组文章数量:1291326
I made a mat table with column reordering and it works partially correct.
The only issue I got is that when I have a sticky header row and the table body is scrolled and then I want to reorder the columns, the boundary is not the mat header row and instead a random row that was behind it, when i started dragging.
I also tried to change cdkDragBoundary but this probably needs to stay on "mat-table" otherwise I cant drag the columns to the edges when the table has an overflow in x axis
Angular version is 17.4
<div class="table-wrapper-container">
<div class="mat-elevation-z8 table-wrapper">
<mat-table
[dataSource]="dataSource"
class="table small-density resizeable"
cdkDropList
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="tableDrop($event)"
matSort
#table
>
<ng-container matColumnDef="position">
<mat-header-cell
*matHeaderCellDef
mat-sort-header
appResize
host="flex-table"
cdkDrag
cdkDragBoundary="mat-table"
cdkDragPreviewClass="drag-preview"
cdkDragPreviewContainer="parent"
cdkDragLockAxis="x"
cdkdrag
>
No.
</mat-header-cell>
<mat-cell *matCellDef="let element"> {{ element.position }} </mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell
*matHeaderCellDef
mat-sort-header
appResize
host="flex-table"
cdkDrag
cdkDragBoundary="mat-table"
cdkDragPreviewClass="drag-preview"
cdkDragPreviewContainer="parent"
cdkDragLockAxis="x"
>
Name
</mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-form-field>
<input matInput [(ngModel)]="element.name" />
</mat-form-field>
</mat-cell>
</ng-container>
<mat-header-row
*matHeaderRowDef="displayedColumns; sticky: true"
#row
></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
</mat-table>
<mat-paginator
[length]="100"
[pageSize]="25"
[pageSizeOptions]="[5, 10, 25]"
>
</mat-paginator>
</div>
</div>
本文标签: angularMat Table with reordering Columns (cdkDrag) not working with sticky header rowStack Overflow
版权声明:本文标题:angular - Mat Table with reordering Columns (cdkDrag) not working with sticky header row - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741528355a2383604.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论