I want to build a table where every column is a response from an API call and contains some elements. I tried different approaches with material table but nothing seems to work. The problem comes from the fact that I try to build it on columns and not on rows (there are different number of elements on every col)
I've also tried with a simple table and it works but then the view doesn't look like it should. Every column is wrapped in an <ng-container>
and it should be displayed as a new column, but it displays them on the same column.
I've also tried an approach using divs and that works fine but then I can not make the header of the table to be sticky and fixed when I scroll down. (also, is not a good idea using divs inside a table)
This is how my table looks now, being the best variant so far:
<table class="mat-table">
<ng-container *ngFor="let elem of selectedCheckValues">
<th class="mat-header-cell">{{ elem.name }}</th>
<tr id="{{element}}" *ngFor="let element of elem.items; let idx=index;" (click)="onRowClick(elem, element)">
<td class="mat-cell">{{element}}</td>
</tr>
</ng-container>
</table>
And this is how my data looks like:
export interface SelectedCheckValues {
name: string;
items: string[];
}
Where name should be the table header and items the elements from the column.