Recommended usage of mat-table generates the following elements structure:
<mat-table>
<mat-header-row>...</mat-header-row>
<mat-row>...</mat-row>
...
<mat-row>...</mat-row>
</mat-table>
Is there a way to force the usage of some custom template in order to wrap regular row elements into some parent one (e.g. div) to separate them from a header row element (in order to make table body scrollable)? Result should be something like:
<mat-table>
<mat-header-row>...</mat-header-row>
<div>
<mat-row>...</mat-row>
...
<mat-row>...</mat-row>
</div>
</mat-table>
The only solution I figured out is a custom table component like:
@Component({
selector: 'my-cool-table',
template: `
<ng-container headerRowPlaceholder></ng-container>
<div>
<ng-container rowPlaceholder></ng-container>
</div>`,
host: {
'class': 'mat-table',
},
styleUrls: [
'my_cool_table.css',
],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyCoolTable<T> extends CdkTable<T> {}
But there are some negative aspects like inheritance of mat-table style sheets. So the question is: is it possible to use custom template for mat-table directly?