angular 中的嵌套 Table 问题?
Nested Table issue in angular?
data = {
SolutionsDetail: [
{
SolutionId: 658,
name: "dk",
id: 1568377327000,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 1234
},
{
ReqId: 5678
}
],
groups: [
{
GroupId: 1,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 1234
},
{
ReqId: 5678
}
]
},
{
GroupId: 2,
requestDetails: [
{
ReqId: 2331
}
,
{
ReqId: 2212
}
]
},
{
GroupId: 3,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 4444
},
{
ReqId: 1111
},
{
ReqId: 2222
}
]
}
]
}
] }
我的工作结构正在显示组和请求 properly.now 我在组外也有 requestDetails。我无法按要求正确显示。(我在 json 中有两个地方请求详细信息,需要按快照显示。)
下面提到的代码旁边显示了组和请求数。
<ng-container *ngFor="let groupRowData of data.SolutionsDetail[0].groups;">
<ng-container *ngFor="let requestDetailData of groupRowData.requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="groupRowData.requestDetails.length">Group {{ groupRowData.GroupId }}</td>
<td>
{{ requestDetailData.ReqId}}
</td>
</tr>
</ng-container>
</ng-container>
This is how i solved
<table border=1>
<ng-container *ngFor="let groupRowData of data.SolutionsDetail[0].groups;">
<ng-container *ngFor="let requestDetailData of groupRowData.requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="groupRowData.requestDetails.length">Group {{ groupRowData.GroupId }}</td>
<td>
{{ requestDetailData.ReqId}}
</td>
</tr>
</ng-container>
</ng-container>
<ng-container *ngFor="let RowData of data.SolutionsDetail[0].requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="data.SolutionsDetail[0].requestDetails.length">NA</td>
<td>
{{ RowData.ReqId}}
</td>
</tr>
</ng-container>
</table>
data = {
SolutionsDetail: [
{
SolutionId: 658,
name: "dk",
id: 1568377327000,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 1234
},
{
ReqId: 5678
}
],
groups: [
{
GroupId: 1,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 1234
},
{
ReqId: 5678
}
]
},
{
GroupId: 2,
requestDetails: [
{
ReqId: 2331
}
,
{
ReqId: 2212
}
]
},
{
GroupId: 3,
requestDetails: [
{
ReqId: 2331
},
{
ReqId: 4444
},
{
ReqId: 1111
},
{
ReqId: 2222
}
]
}
]
}
] }
我的工作结构正在显示组和请求 properly.now 我在组外也有 requestDetails。我无法按要求正确显示。(我在 json 中有两个地方请求详细信息,需要按快照显示。)
下面提到的代码旁边显示了组和请求数。
<ng-container *ngFor="let groupRowData of data.SolutionsDetail[0].groups;">
<ng-container *ngFor="let requestDetailData of groupRowData.requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="groupRowData.requestDetails.length">Group {{ groupRowData.GroupId }}</td>
<td>
{{ requestDetailData.ReqId}}
</td>
</tr>
</ng-container>
</ng-container>
This is how i solved
<table border=1>
<ng-container *ngFor="let groupRowData of data.SolutionsDetail[0].groups;">
<ng-container *ngFor="let requestDetailData of groupRowData.requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="groupRowData.requestDetails.length">Group {{ groupRowData.GroupId }}</td>
<td>
{{ requestDetailData.ReqId}}
</td>
</tr>
</ng-container>
</ng-container>
<ng-container *ngFor="let RowData of data.SolutionsDetail[0].requestDetails; let $index = index">
<tr>
<td *ngIf="$index===0;" [attr.rowspan]="data.SolutionsDetail[0].requestDetails.length">NA</td>
<td>
{{ RowData.ReqId}}
</td>
</tr>
</ng-container>
</table>