Angular Material table drag and drop columns with sorting not wroking

此生再无相见时 提交于 2019-12-23 22:56:03

问题


The angular material table with sorting doesn't work properly with drag-and-drop.

Here's what I've got so far, it kinda works where the sorting works with a specific column after being dragged and dropped. But still has weird functionality.

Stackblitz

I want to be able to use the normal sorting functionality of Material Table while being able to drag and drop columns.


回答1:


matSort needs to be on the mat-table element

<mat-table [dataSource]="dataSource" class="mat-elevation-z8" cdkDropListGroup matSort>

rather than on the ng-container

<mat-table [dataSource]="dataSource" class="mat-elevation-z8" cdkDropListGroup>
  <ng-container *ngFor="let column of columns; let i = index" [matColumnDef]="column.field" matSort>


来源:https://stackoverflow.com/questions/56236058/angular-material-table-drag-and-drop-columns-with-sorting-not-wroking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!