I found a lot of solutions, but none of them working with mat-list. It necessary for me, because mat-list is only one solution where drag&drop working ( table had mat-table always have this issue for me and i can't find solution how to fix it). There is part of my html from working mat-list with drag&drop, but no idea how to add sorting:
<div *ngIf="viewList" fxFlex class="list-borders">
<mat-list cdkDropList (cdkDropListDropped)="drop($event)">
<mat-list-item>
<mat-grid-list cols="16" rowHeight="50px" fxFlex class="title-row">
<mat-grid-tile colspan="4" class="title-tile">
Name
</mat-grid-tile>
<mat-grid-tile class="title-tile">
Extension
</mat-grid-tile>
<mat-grid-tile class="title-tile">
Status
</mat-grid-tile>
<mat-grid-tile class="title-tile">
Size
</mat-grid-tile>
<mat-grid-tile colspan="2" class="title-tile">
Server version
</mat-grid-tile>
<mat-grid-tile colspan="5" class="title-tile">
Last modified (server)
</mat-grid-tile>
<mat-grid-tile colspan="2">
Segment name
</mat-grid-tile>
</mat-grid-list>
</mat-list-item>
<mat-list-item cdkDrag *ngFor="let element of Elements" (click)="navigate(element)" (contextmenu)="onContextMenu($event, element)" >
<mat-grid-list cols="16" rowHeight="50px" fxFlex>
<mat-grid-tile colspan="4">
<mat-icon *ngIf="element.isFolder" color="primary">
folder
</mat-icon>
<mat-icon *ngIf="!element.isFolder" color="primary">
insert_drive_file
</mat-icon>
{{element.name}}
</mat-grid-tile>
<mat-grid-tile>
{{element.extension}}
</mat-grid-tile>
<mat-grid-tile>
<mat-icon *ngIf="element.status == 'online'" class="status-online">
check_circle
</mat-icon>
<mat-icon *ngIf="element.status == 'unknown'" class="status-unknown">
help
</mat-icon>
<mat-icon *ngIf="element.status == 'offline'" class="status-offline">
report_problem
</mat-icon>
</mat-grid-tile>
<mat-grid-tile>
{{element.size}}
</mat-grid-tile>
<mat-grid-tile colspan="2">
{{element.serverVersion}}
</mat-grid-tile>
<mat-grid-tile colspan="5">
{{element.lastModified}}
</mat-grid-tile>
<mat-grid-tile colspan="2">
{{element.segmentName}}
</mat-grid-tile>
</mat-grid-list>
</mat-list-item>
</mat-list>
</div>
Attepmt 1
This code: <mat-grid-tile mat-sort-header="name" colspan="4" class="title-tile">
Causes:
More than one component matched on this element. Make sure that only one component's selector can match a given element. Conflicting components: MatGridTile,MatSortHeaderng(0)
Update 1
Elements:
export class Element {
id?: string
isFolder: boolean
name: string
parent: string
extension?: string
status?: string
size?: number
serverVersion?: string
lastModified?: string
segmentName?: string
}
And few example elements:
ngOnInit() {
const folderA = this.fileService.add(
{
name: 'Movies',
isFolder: true,
parent: 'root',
status: 'online',
size: 0,
serverVersion: '5',
lastModified: 'added yesterday',
segmentName: 'IDK'
}
);
this.fileService.add(
{
name: 'Trash',
isFolder: true,
parent: 'root',
status: 'unknown',
size: 0,
serverVersion: '22',
lastModified: 'added 2 years ago',
segmentName: 'WTF'
}
);
this.fileService.add(
{
name: 'how_to_fix_it',
isFolder: false,
parent: 'root',
extension: '.txt',
status: 'offline',
size: 2048,
serverVersion: '1',
lastModified: 'added 1 week ago',
segmentName: 'NI'
}
);
this.fileService.add(
{
name: 'cute',
isFolder: false,
parent: 'root',
extension: '.jpg',
status: 'online',
size: 4096,
serverVersion: '12',
lastModified: 'added today',
segmentName: 'WUT'
}
);
const temp = (folderA.id as string);
this.fileService.add(
{
name: 'Game of thrones',
isFolder: true,
parent: temp,
status: 'online',
size: 0,
serverVersion: '5',
lastModified: 'added month ago',
segmentName: 'OMG'
}
);
this.updateFileElementQuery();
They came as input:
@Input() elements: Element[];