Check the official mat-table link below.
https://material.angular.io/components/table/overview
When we had to show more than 50 records per page, user will have to scroll down to see the bottom records. When we scroll down, header should stay static on top of the table and it helps the user to easily identify which column is what.
No working sample available
.mat-header-row {
position: sticky;
top: 0;
background-color: inherit;
}
@oktav777 You should also include position: -webkit-sticky
for Safari browsers.
.mat-header-row {
position: sticky;
position: -webkit-sticky;
top: 0;
background-color: inherit;
}
@Chan4077 preprocessor should autoprefix it.
@oktav777 the css work .but if the hearder has selection,when scroll the below will occur
before scoll:
when scroll:
Thanks oktav and Chan. The css works fine. But not working in IE 11
@stevenmi add z-index
so it looks like:
.mat-header-row {
top: 0;
position: sticky;
z-index: 1;
background-color: inherit;
}
@jayakrishna-v position: sticky
is not supported in IE. If you really need IE, you have to override the styles or change the layout of tables.
ok. I have a basic question. Does Angular Material support IE browsers?
@jayakrishna-v Yes, IE11 is supported, see here
ok. Thank you
i have tried with solution you have provided to fix mat-tab-header , but not working
Solution does not work if the table is inside mat-sidenav-container
. Any suggestion?
@soumyakantiroychowdhury did you find a solution?
@Ch4osCosmo I did not try after that. Will post here if I get a solution.
is there a fix for this?
Try this:
::ng-deep .mat-tab-header {
top: 0;
position: sticky !important;
z-index: 999 !important;
background-color: white;
}
I want to make the first four columns as sticky. Is there any way in angular mat-table??
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
Tried this solution on @angular/material 8.1.4 . It's working
I don't understand why would you say Angular Material is compatible with IE 11, if the property 'sticky: true' of mat table's header is not working in IE 11 ?
In addition I see a case where we would need fixed position on header (and not sticky). Suppose you have a fixed header. Setting sticky table's headers would cause them to stick underneath the fixed header, making it invisible.
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._
Most helpful comment
@stevenmi add
z-index
so it looks like:@jayakrishna-v
position: sticky
is not supported in IE. If you really need IE, you have to override the styles or change the layout of tables.