gpt4 book ai didi

javascript - 需要根据行索引隐藏 ngx-datatable 的行

转载 作者:太空狗 更新时间:2023-10-29 19:26:16 27 4
gpt4 key购买 nike

我有一个数据表,其中显示分支数据,但需要隐藏索引为 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>

我试着用 *ngIf 指令来做,但它不起作用。我该如何解决这个问题?

最佳答案

尝试用 span 包装要显示的数据,然后在 span 标签内使用 ngIf:

<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>

关于javascript - 需要根据行索引隐藏 ngx-datatable 的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50040146/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com