I am trying to implement Hierarchical Grid in my Angular 2 application similar to this one http://demos.telerik.com/kendo-ui/grid/hierarchy
So I started out by creating two components. The Parent Component is for parent table and Child Component is for child table. So when click on row from parent table, the child table will load right below it (like above example).
This is how my html looks like
<div class="row">
<div class="col-md-12">
<h1>{{pageTitle}}</h1>
<table class="table table-striped">
<thead>
<tr>
<td></td>
<td>User Name</td>
<td>Email</td>
<td>Billing Method</td>
</tr>
</thead>
<tbody>
<tr class="master-row" *ngFor="#invoice of invoices; #i = index">
<td><button (click)="getDetail(invoice)"><i class="glyphicon glyphicon-chevron-right"></i></button></td>
<td>{{invoice.username}}</td>
<td>{{invoice.email}}</td>
<td>{{invoice.billingMethod}}</td>
</tr>
</tbody>
</table>
</div>
</div>
But I am having two issues:
1) How to load child table on a correct location in DOM? The problem is when my parent table render, all of it's rows gets created using ngFor directive. Now when click on a row, how to load it's child table right below it? How to identify the location?
2) In order to load child table, I was thinking to use DynamicComponentLoader Class, but looks like the communication between Components won't be possible when using DCL.
Please suggest
nestcomponents. Check this plunker it should guide youDCLrequire the location in DOM where to load thecomponent?DynamicComponentLoaderin your situation. But here is a simple plunker to show you how to reference the target element. " check the console after clicking on a row"trhas to be directly belowtbodyortable. But, if you want to use DCL, then you need an anchor element that will be between thetrandtbodywhich will mess up the table. If you want to use*ngIfto show thetrthen,trhas to be either inside the parenttror at the bottom of the table. These kind of table restrictions are the reason I preferdivs