I'm looking for a working virtual scroll table with fixed headers, so I found the Cdk which is great but the documentation is really difficult to follow. At the moment I'm trying to combine the CdkTable
with CdkVirtualScoll
.
All working examples I could found are using Material table, but I don't.
So how can I get CdkVirtualScoll
get to work? Here is what I have done so far (from the examples):
<cdk-virtual-scroll-viewport>
<cdk-table [dataSource]="dataSource">
<ng-container cdkColumnDef="username">
<cdk-header-cell *cdkHeaderCellDef> User name </cdk-header-cell>
<cdk-cell *cdkCellDef="let row"> {{row.username}} </cdk-cell>
</ng-container>
<ng-container cdkColumnDef="title">
<cdk-header-cell *cdkHeaderCellDef> Title </cdk-header-cell>
<cdk-cell *cdkCellDef="let row"> {{row.title}} </cdk-cell>
</ng-container>
<!-- Header and Row Declarations -->
<cdk-header-row *cdkHeaderRowDef="['username', 'age']"></cdk-header-row>
<cdk-row *cdkRowDef="let row; columns: ['username', 'age']"></cdk-row>
</cdk-table>
</cdk-virtual-scroll-viewport>
As in the documentation is written, the table was wrapped into the scrolling viewport. But how and where can I set the *cdkVirtualFor
now?
Thx for your help!