5
votes

I'm new with Angular 4 and ngx-datatable and I'm getting stuck. Now, I have a ngx-datatable with a simple rowDetail, just like it's shown here. The problem is that I need the rowDetail to contain another ngx-datatable and I don't know if this is even possible.

Could anybody give me some clue?

Thanks in advance!

1

1 Answers

5
votes

Ok, finally it was no big deal at all. I leave here a sample template of this type of table, for people getting stuck as I did:

  <ngx-datatable #myTable class="material expandable" [rows]="rows" columnMode="flex" [headerHeight]="headerHeight"
    [footerHeight]="footerHeight" [rowHeight]="rowHeight" [loadingIndicator]="loadingIndicator" [externalPaging]="true"
    [count]="page.totalElements" [offset]="page.pageNumber" [limit]="page.size" (page)='setPage($event)'>
    <ngx-datatable-row-detail [rowHeight]="150" #myDetailRow (toggle)="onDetailToggle($event)">
      <ng-template let-row="row" let-expanded="expanded" ngx-datatable-row-detail-template>
        <div>
          <ngx-datatable #myDaughter columnMode="flex" [headerHeight]="falsey" [rows]="getDetailRows(row)"
            [footerHeight]="footerHeight" [rowHeight]="rowHeight" [loadingIndicator]="loadingIndicator" [externalPaging]="true"
            [count]="detailRows.length" [offset]="page.pageNumber" [limit]="page.size" (page)='setPage($event)'>
            <ngx-datatable-column name="A" prop="col_a"></ngx-datatable-column>
            <ngx-datatable-column name="B" prop="col_b"></ngx-datatable-column>
            <ngx-datatable-column name="C" prop="col_c"></ngx-datatable-column>
          </ngx-datatable>
        </div>
      </ng-template>
    </ngx-datatable-row-detail>
    <ngx-datatable-column [sortable]="false" [draggable]="false">
      <ng-template let-row="row" let-expanded="expanded" ngx-datatable-cell-template>
        <button md-icon-button [class.datatable-icon-right]="!expanded" [class.datatable-icon-down]="expanded" title="Expand/Collapse Row"
          (click)="toggleExpandRow(row)"></button>
      </ng-template>
    </ngx-datatable-column>
    <ngx-datatable-column name="A" prop="col_a"></ngx-datatable-column>
    <ngx-datatable-column name="B" prop="col_b"></ngx-datatable-column>
    <ngx-datatable-column name="C" prop="col_c"></ngx-datatable-column>
  </ngx-datatable>