【发布时间】:2021-05-31 14:47:38
【问题描述】:
我想帮助我更新使用 MatTable 的动态表中的记录。 在我的组件中获取:
getComponentsFactualGeneral(pil: number){
this.diagnosticoService.readPilarParamFormId(pil).pipe().subscribe(pilar=>{
this.facgeneral = [];
(pilar as Pilari[]).forEach( getpilar => {
this.diagnosticoService.readComponentsPilarId(getpilar.idPilar).subscribe( comp=>{
getpilar.components = comp;
});
this.facgeneral.push(getpilar);
});
});
}
这会生成以下内容:
html 有:
<mat-tab>
<ng-template mat-tab-label>
<span (click)="getComponentsFormaGeneral(2)">Formal general</span>
</ng-template>
<mat-accordion class="example-headers-align" multi>
<mat-expansion-panel *ngFor="let item of fgeneral">
<mat-expansion-panel-header>
<mat-panel-title> {{ item.descripcion }} </mat-panel-title>
</mat-expansion-panel-header>
<div class="table-responsive">
<table mat-table [dataSource]="item.components" class="mat-elevation-z8"> <!-- here generate datasource -->
<ng-container matColumnDef="nombreestandar">
<th mat-header-cell *matHeaderCellDef> Estandar </th>
<td mat-cell *matCellDef="let element"> {{element.nombreestandar}} </td>
</ng-container>
<ng-container matColumnDef="nombrecomponente">
<th mat-header-cell *matHeaderCellDef> Componente </th>
<td mat-cell *matCellDef="let element"> {{element.nombrecomponente}} </td>
</ng-container>
<ng-container matColumnDef="evidencia">
<th mat-header-cell *matHeaderCellDef> Evidencia </th>
<td mat-cell *matCellDef="let element"> {{ element.evidencia }}
</td>
</ng-container>
<ng-container matColumnDef="conclusionCumple">
<th mat-header-cell *matHeaderCellDef> Cumplimiento </th>
<td mat-cell *matCellDef="let element"> {{ element.conclusionCumple }}
<ng-template #elseBlock>
No cumple
</ng-template>
</td>
</ng-container>
<ng-container matColumnDef="comentariosCc">
<th mat-header-cell *matHeaderCellDef> Comentario </th>
<td mat-cell *matCellDef="let element"> {{ element.comentariosCc }}
</td>
</ng-container>
<ng-container matColumnDef="comentariosComite">
<th mat-header-cell *matHeaderCellDef> Comentarios Comité </th>
<td mat-cell *matCellDef="let element"> {{ element.comentariosComite }}
</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Acciones </th>
<td mat-cell *matCellDef="let e; let i=index;">
<button mat-icon-button color="primary" (click)="openDialog(e.idRespuestamacro,e.idEstandar,e.idFormulario,e.idInstitucion,e.idPilar,e.paramComponente)">
<mat-icon aria-label="Edit">edit</mat-icon>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</mat-expansion-panel>
</mat-accordion>
</mat-tab>
从组件生成数据源 [dataSource]="item.components" 现在我需要在编辑后更新一行,但是如果数据源是从“item.components”生成的,我该怎么办。
谢谢
【问题讨论】:
标签: json angular angular-material