Any help or hint would be greatly appreciated. I am using Angular 8 with bootstrap 4. Here is my home.component.html
<table class="table" border="0">
<thead class="thead-light">
<tr>
<th scope="col">#</th>
<th scope="col">Report Issued Date</th>
<th scope="col">Report Name and ID</th>
<th scope="col">Report Status</th>
</tr>
</thead>
<tbody *ngFor="let report of patient?.listDiagnosticReport">
<tr>
<td>{{report.id}}
</td>
<td>{{report.reportIssuedDate}}</td>
<td>
<button (click)="onShow(report.reportId)">
{{report.reportName+"("+report.reportId+")"}}
</button>
</td>
<td>{{report.reportStatus}}</td>
</tr>
<tr id="{{report.reportId}}" *ngFor="let procedureRequest of report?.listOfProcedures" [hidden]="showRow">
<td [attr.colspan]="4">
Specimen Collected By: {{procedureRequest.procedureName}}
<br/>
Specimen Collection Date: {{procedureRequest.datePerformed}}
<br/>
Procedure Name: {{procedureRequest.procedureName}}
</td>
</tr>
</tbody>
Here is my home.component.ts:
export class HomeComponent implements OnInit {
showRow: boolean = true;
onShow(rowId: string)
{
if (this.showRow === true)
{
this.showRow = false;
}
else
{
this.showRow = true;
}
}
I placed an id on the row and when it first load all of the rows disappear. When I click on the button it trigger the onShow method with the reportId as an argument. How can I make the particular row show in Angualr 8?
Thank you for everyone's suggestion and help. I am able to hide the row at the beginning and when click the button show the row.
onShow(reportId: string) {
const el = <HTMLElement>document.querySelector(`#${reportId}`);
if (el.hidden === false) {
el.hidden = true;
} else {
// el.classList.remove('hidden');
el.hidden = false;
}
}
My problem is that I have more than one row with the same id. In fact I have 3 rows with the same Id and when I click the button it only shows 1 row and not the other 2 rows.
This is my home.component.html:
<tr id="{{report.reportId}}" *ngFor="let procedureRequest of report?.listOfProcedures" [hidden]="showRow">
<td [attr.colspan]="4">
Specimen Collected By: {{procedureRequest.procedureName}}
<br/>
Specimen Collection Date: {{procedureRequest.datePerformed}}
<br/>
Procedure Name: {{procedureRequest.procedureName}}
</td>
</tr>