When we put the condition in Mat-paginator, pagination is not working.
Hi when we put the condition still this is not working.
<mat-paginator *ngIf="allItems ?.length > 0" #paginator [pageSize]="50" [pageSizeOptions]="[1,2,4,20, 40,100,150,200]">
If we remove the *ngIf="allItems ?.length > 0", this is working.
Make a stackblitz reproduction of the problem.
If we put any condition it wont work.
There is no condition in below code.So it will work. <mat-paginator #paginator [pageSize]="50" [pageSizeOptions]="[1,2,4,20, 40,100,150,200]">
when we put the condition, this is not working.
<mat-paginator *ngIf="allItems ?.length > 0" #paginator [pageSize]="50" [pageSizeOptions]="[1,2,4,20, 40,100,150,200]">
What if you encapsule the mat-paginator into a div with ngIf ? To workaround for the moment.
After if condition, now sorting and pagination both are not working. If i will remove if condition both will work. But how i will add the if condition.
<div *ngIf="allItems ?.length > 0">
<mat-table class="markstable" #table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="admissionno">
<mat-header-cell class="markstable" *matHeaderCellDef mat-sort-header>
<div class="tableheader">Admission No</div>
</mat-header-cell>
<mat-cell class="markscell" *matCellDef="let feePayment">
{{feePayment.admissionno}}
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
<mat-paginator #paginator [pageSize]="50" [pageSizeOptions]="[2,20, 40,100,150,200]">
</mat-paginator>
</div>
Closing this issue as it does not follow the issue template. Please file a new issue that follows the template, which gives the team the information needed to investigate
I suspect you are trying to get the paginator using ViewChild, which won't work since the if statement will block it from getting the child.
Put pagination outside of NgIF and apply condition on paginator using following
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.