Reputation: 101
I am trying to create an scrollable table horizontal and vertical scroll bars with fixed headers using ionic grid.
i am able to achieve the scroll part but not able to make the headers fixed.
HTML:
<ion-content class="{{selectedTheme}} inventory-content">
<div class="{{selectedTheme}} reports-table">
<ion-grid>
<ion-row nowrap class="headers">
<ion-col size="5" class="single-border">
Name
</ion-col>
<ion-col size="2" class="single-border">
Model
</ion-col>
<ion-col size="3" class="single-border">
Make
</ion-col>
<ion-col size="3" class="single-border">
Year
</ion-col>
</ion-row>
<ion-row nowrap class="content" *ngFor="let inventory of sortedInventoryList">
<ion-col size="5"> {{ inventory.Name }} </ion-col>
<ion-col size="2"> {{ inventory.Model }} </ion-col>
<ion-col size="3"> {{ inventory.Make }} </ion-col>
<ion-col size="3"> {{ inventory.Year }} </ion-col>
</ion-row>
</ion-grid>
</div>
</ion-content>
CSS:
.reports-table {
overflow-x: auto;
}
.inventory-content {
background-color: #f0f1f2;
}
.headers {
color: #454f63;
font-family: "Open Sans";
font-weight: bold;
font-size: 14px;
margin-top: 10px;
word-wrap: break-word;
}
.border,
.single-border {
border-bottom: 2px solid #989898;
}
.single-border {
padding-top: 12px;
}
.content {
color: #454f63;
font-family: "Open Sans";
font-size: 10px;
}
Upvotes: 3
Views: 3622
Reputation: 1
Adding to Ajt's answer, I also had to remove the .reports-table css. Otherwise, the header row scrolled with the rest of the grid.
Upvotes: 0
Reputation: 1867
It is late.. but it is use for some one else.. below code works fine for me Change ur herader css to
.headers {
color: #454f63;
font-family: "Open Sans";
font-weight: bold;
font-size: 14px;
margin-top: 10px;
word-wrap: break-word;
background-color: #f0f1f2;;
// Fixed Header
position: sticky;
top: 0;
left: 0;
right: 0;
z-index: 9999;
}
Upvotes: 2