6

我是 Angular 4 的新手,ngx-datatable我被卡住了。现在,我有一个简单的 ngx-datatable rowDetail,就像这里显示的一样。问题是我需要rowDetail包含另一个ngx-datatable,我不知道这是否可能。

有人可以给我一些线索吗?

提前致谢!

4

1 回答 1

6

好吧,最后这没什么大不了的。我在这里留下了一个此类表格的示例模板,以供像我一样陷入困境的人们:

  <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>
于 2017-09-23T00:46:21.067 回答