I have an angular material data table with around 200 records. I have used mat-paginator and mat-sort on the data table. When I click on the sort icon or change the paginator number from 25 to 50 or 100, it freezes for 4-5 seconds. It should not happen for such small number of records, should it?
Here's the code:
@ViewChild(MatSort, { static: true }) sort: MatSort;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
changeDetection: ChangeDetectionStrategy.OnPush,
ngOnInit(): void {
this._sleeve.getPublishedSleeves().subscribe((sleeves: Sleeve[]) => {
this.dataSource = new MatTableDataSource(sleeves);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.dataSource.filterPredicate = this.createFilter();
this.dataSource.filter = JSON.stringify(this.filterValues); // applying filters if any
});
}
It works the same when I put the above logic in ngAfterViewInit
instead of ngOnInit