I'm using Material table with pagination and sortable modules. I know that a lot of subjects are talking about multiple tables in one component. But the problem is that i'm in a case where it does not work and i don't understand why..
Paginator is working properly with my 2 tables. But MatSort is just not working.. I put my mouse in the cell, it shows that i can click to sort, but there is no changes on the data..
displayedColumnsOne: string[] = ['group', 'action'];
@ViewChild('tableOnePaginator', { static: false }) tableOnePaginator!: MatPaginator;
@ViewChild('tableOneSort', { static: false }) tableOneSort!: MatSort;
dataSource = new MatTableDataSource<any>();
....
updateDataTable(): void {
this.changeDetectorRefs.detectChanges();
this.dataSource.paginator = this.tableOnePaginator;
this.dataSource.sort = this.tableOneSort;
}
<mat-table #tableOneSort="matSort" matTableExporter [dataSource]="dataSource" matSort matSortActive="group" matSortDirection="desc" matSortDisableClear class="mat-elevation-z8 col-md-12 col-xl-6 offset-xl-3" #exporter="matTableExporter">
...
<ng-container matColumnDef="group">
<mat-header-cell *matHeaderCellDef mat-sort-header>Groupe</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element}} </mat-cell>
</ng-container>
...
<mat-paginator #tableOnePaginator="matPaginator" [pageSizeOptions]="[10, 15, 20]" showFirstLastButtons aria-label="Nombre d'élements par page"></mat-paginator>
user.module
MatTableExporterModule,
MatTableModule,
MatPaginatorModule,
MatSortModule,
app.module
MatTableModule,
MatTableExporterModule,
MatPaginatorModule,
MatSortModule,