角度材料表拖放列,排序不工作 [英] Angular Material table drag and drop columns with sorting not wroking

查看:23
本文介绍了角度材料表拖放列,排序不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带排序的有角材料表无法通过拖放正常工作.

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.

推荐答案

matSort 需要在 mat-table 元素上

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

而不是在 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>

这篇关于角度材料表拖放列,排序不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆