I'm looking at the reorderable columns example on stackblitz.
In particular I see the html
<table mat-table
[dataSource]="dataSource"
cdkDropList
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="drop($event)">
I've defined the drop inside MytableComponent
export class MytableComponent implements AfterViewInit {
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
@ViewChild(MatTable) table!: MatTable<MytableItem>;
dataSource: MytableDataSource;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['id', 'name', 'dateOfBirth'];
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.displayedColumns, event.previousIndex, event.currentIndex);
}
constructor() {
this.dataSource = new MytableDataSource();
}
ngAfterViewInit(): void {
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
this.table.dataSource = this.dataSource;
}
}
The build fails with an error
Error: src/app/mytable/mytable.component.html:5:35 - error TS2345: Argument of type 'Event' is not assignable to parameter of type 'CdkDragDrop<string[], string[]>'.
Type 'Event' is missing the following properties from type 'CdkDragDrop<string[], string[]>': previousIndex, currentIndex, item, container, and
3 more.