Can Angular drag & drop work with mat-table with paging and sorting enabled?

Discussão em 'Angular' iniciado por Michalis B., Setembro 17, 2024.

  1. Michalis B.

    Michalis B. Guest

    I have already implemented a solution where drag and drop is possible between two mat-tables with arrays for datasources.

    At the time I am using the code from Angular Material Schematics for the drop function like the following:

    drop(event: CdkDragDrop<MyObject[]>) {
    if (event.previousContainer === event.container) {
    moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
    } else {
    transferArrayItem(event.previousContainer.data,
    event.container.data,
    event.previousIndex,
    event.currentIndex);
    }
    }


    However when paging and sorting was added and I switched my datasource to MatTableDatasource the drag and drop functionality stopped working.

    In general, is it possible for drag & drop to work on a mat-table with paging and sorting enabled?

    Continue reading...

Compartilhe esta Página