I have a situation where the data I receive from my backend is column-oriented. An example of how this data looks like is this:
[
{ columnName: "ID", cells: [1, 2, 3, 4, 5] },
{ columnName: "Name", cells: ["a", "b", "c", "d", "e"] }
]
So far I have managed to configure my mat-table like this:
<table mat-table [dataSource]="data" class="mat-elevation-z8">
<ng-container [matColumnDef]="column" *ngFor="let column of displayedColumns">
<th mat-header-cell *matHeaderCellDef> {{column}} </th>
<td mat-cell *matCellDef="let element">{{element | json}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
which gives me the following result:
while in reality I'd like to see the table like this:
|------|------|
| ID | NAME |
|------|------|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
Is there some way to adjust the matRowDef so it defines the cells property as rows? Ideally I would just like to change this in the mat-table, so I don't need to manipulate my data and later convert it back.

JSONlike this.. - Farhat Zaman