最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Need to hide row of ngx-datatable based on row index - Stack Overflow

programmeradmin1浏览0评论

I have an data table where I show data of branches, but need to hide the item with the index of 0.

    <ngx-datatable
          class="data-table table-responsive task-list-table"
          [rows]="branches"
          [loadingIndicator]="loadingIndicator"
          [columnMode]="'force'"
          [headerHeight]="50"
          [footerHeight]="50"
          [limit]="10"
          [rowHeight]="66"
          [reorderable]="reorderable">
          <ngx-datatable-column name="Branch Office Name">
            <ng-template let-rowIndex="rowIndex" *ngIf="rowIndex != 0" let- 
            branch="row" ngx-datatable-cell-template>
              {{branch['name']}}
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Parent Branch">
            <ng-template let-rowIndex="rowIndex" *ngIf="rowIndex != 0" let- 
             branch="row" ngx-datatable-cell-template>
              {{branch['parentOrganizationName']}}
            </ng-template>
          </ngx-datatable-column>
  </ngx-datatable>

I tried do it with *ngIf directive but it doesn't work. How can I solve this?

I have an data table where I show data of branches, but need to hide the item with the index of 0.

    <ngx-datatable
          class="data-table table-responsive task-list-table"
          [rows]="branches"
          [loadingIndicator]="loadingIndicator"
          [columnMode]="'force'"
          [headerHeight]="50"
          [footerHeight]="50"
          [limit]="10"
          [rowHeight]="66"
          [reorderable]="reorderable">
          <ngx-datatable-column name="Branch Office Name">
            <ng-template let-rowIndex="rowIndex" *ngIf="rowIndex != 0" let- 
            branch="row" ngx-datatable-cell-template>
              {{branch['name']}}
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Parent Branch">
            <ng-template let-rowIndex="rowIndex" *ngIf="rowIndex != 0" let- 
             branch="row" ngx-datatable-cell-template>
              {{branch['parentOrganizationName']}}
            </ng-template>
          </ngx-datatable-column>
  </ngx-datatable>

I tried do it with *ngIf directive but it doesn't work. How can I solve this?

Share Improve this question edited Nov 5, 2019 at 12:06 Hovhannes Gevorgyan asked Apr 26, 2018 at 10:01 Hovhannes GevorgyanHovhannes Gevorgyan 5521 gold badge8 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Try wrapping the data to be displayed with a span, then use the ngIf inside the span tag:

<ngx-datatable
          class="data-table table-responsive task-list-table"
          [rows]="branches"
          [loadingIndicator]="loadingIndicator"
          [columnMode]="'force'"
          [headerHeight]="50"
          [footerHeight]="50"
          [limit]="10"
          [rowHeight]="66"
          [reorderable]="reorderable">
          <ngx-datatable-column name="Branch Office Name">
            <ng-template let-rowIndex="rowIndex" let- 
            branch="row" ngx-datatable-cell-template>
              <span *ngIf="rowIndex != 0">
                {{branch['name']}}
              </span>
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Parent Branch">
            <ng-template let-rowIndex="rowIndex" let- 
             branch="row" ngx-datatable-cell-template>
              <span *ngIf="rowIndex != 0">
                {{branch['parentOrganizationName']}}
              </span>
            </ng-template>
          </ngx-datatable-column>
  </ngx-datatable>
发布评论

评论列表(0)

  1. 暂无评论