I have a Mat table with Header and beneath the table I have added a paginator component , I have adjusted paginator component to be as a footer seen in both the images.
Now the question is I want Rows to be scrollable with the tables Header and Footer(i.e Paginator Component) to be fixed at one place.
But Currently As shown in the second Image if I select the 10 rows then the height of the table increases and I get the Scroll on the main Div.
Tried hard for hours but wasn't able to do it I will put the Exact Code which I have Written so that It can be better ShowCased.
Below is my html file
<div class="outerDiv">
<div class="table-container">
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
<!-- Position Column -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Id </th>
<td mat-cell *matCellDef="let element"> {{element.id}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Email </th>
<td mat-cell *matCellDef="let element"> {{element.email}} </td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="phone">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Mobile Number </th>
<td mat-cell *matCellDef="let element"> {{element.phone}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns;sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
<div class="paginator">
<mat-paginator [length]="2"
[pageSize]="5"
[pageSizeOptions]="[5, 10]">
</mat-paginator>
</div>
</div>
Below is My css file
.mat-table {
overflow: auto;
max-height: 500px;
}
th.mat-sort-header-sorted {
color: black;
}
.table-container{
margin-top: 10px;
max-height: 300px;
overflow: auto
}
.outerDiv{
display: block;
padding-left: 226px;
padding-top: 67px;
padding-bottom: 67px;
}
.paginator{
margin-right: 155px;
width: 100%;
max-width: 80%;
position: sticky;
}
Now the table with 10 rows



