I wrote a resize service that works greats for all resize events. I'm able to resize divs and whatnot, but I'm struggling with my "fixed size" table. The only way I can get it to be a scrollable table is by hard-coding the height in the CSS. I'm trying to make it so the table resizes with the screen. What am I doing wrong? Please forgive my awful coding practices below.
Table code:
<table class="table table-fixed" id="div-table" [style.scrollheight]="tableHeight">
<thead>
<tr>
<th class="col-xs-9">Division</th>
<th class="col-xs-3 text-left">Status</th>
</tr>
<tr *ngIf="showsearch">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
<input type="text" class="form-control" placeholder="Search">
</div>
</tr>
</thead>
<tbody [style.scrollheight]="tableHeight">
<tr class="tabledata" *ngFor="let division of divisions" (click)="onDivisionChange(division)" [class.selectedrow]="getClass(division)">
<td class="col-xs-9 text-left">{{division.Name}}</td>
<td class="col-xs-3 text-left">{{division.isActive==true? "Active":"Inactive"}}</td>
</tr>
</tbody>
<td colspan="2" style="width: 100%" *ngIf="addnew"><button class="btn btn-info" style="width: 100%">Add New Division</button></td>
</table>
CSS:
.table-fixed thead {
width: 97%;
}
.table-fixed {
overflow-y: auto;
width: 100%;
}
.table-fixed thead, .table-fixed tbody, .table-fixed tr, .table-fixed td, .table-fixed th {
display: block;
}
.table-fixed tbody td, .table-fixed thead > tr> th {
float: left;
border-bottom-width: 0;
}
Angular:
tableHeight: SafeStyle;
constructor(
private sanitizer: DomSanitizer,
private resizeService: ResizeService) {
resizeService.height$.subscribe((value:any) => {
this.tableHeight = sanitizer.bypassSecurityTrustStyle(`height: (value-157) +'px'`);
});
}