Попытка реализовать сортировку матов по таблице, но сортировка не определена. Я перепробовал все, что мог найти в документации, но ничего не работает. (Удалено ngIf, замените stati c на false, используя все ngAfterViewInit hook без результата)
Я использую [hidden], чтобы скрыть компонент. Любая помощь будет оценена!
--- TS ---
import { Component, ViewChild, Input, AfterViewInit } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ReportResponse, ReportResponseColumnLabel } from '../../report-response.model';
import { ReportDimension } from '../../report-dimension.enum';
@Component({
selector: 'app-reporting-table',
templateUrl: './reporting-table.component.html',
styleUrls: ['./reporting-table.component.scss'],
})
export class ReportingTableComponent implements AfterViewInit {
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild(MatSort, {static: true}) sort: MatSort;
@Input()
set reportResult(value: ReportResponse[]) {
this.setColumns(value);
this.dataSource.data = value;
};
dataSource = new MatTableDataSource<ReportResponse>();
columns = [];
ReportResponseColumnLabel = ReportResponseColumnLabel;
constructor() {
}
ngAfterViewInit(): void {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
console.log(this.sort);
}
}