admin管理员组文章数量:1392054
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.
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.
Share Improve this question asked May 21, 2019 at 10:15 sunalivesunalive 3254 silver badges15 bronze badges 3-
Drag and drop isn't working on the stackblitz. I think your stackblitz needs a theme (e.g. add
@import '@angular/material/prebuilt-themes/deeppurple-amber.css';
tostyles.css
) andhammerjs
(import 'hammerjs';
inapp.ponent.ts
) – Andrew Allen Commented May 21, 2019 at 10:30 - I've updated the stackblitz with your remendations. Also if you drag the column header then it drags the whole column, there is no dragging on the cells. – sunalive Commented May 21, 2019 at 10:35
- You're the man btw. Haven't found a sorting for the column yet and your stackblitz worked straight away. If you mind I posted it on their github as a reference. github./angular/ponents/issues/13776 – Swoox Commented May 21, 2019 at 14:15
1 Answer
Reset to default 4matSort
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>
本文标签: javascriptAngular Material table drag and drop columns with sorting not wrokingStack Overflow
版权声明:本文标题:javascript - Angular Material table drag and drop columns with sorting not wroking - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744782537a2624799.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论