javascript - Need to hide row of ngx-datatable based on row index
问题描述
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?
解决方案
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>
推荐阅读
- r - 未能使用 diagrammeR 的 grViz 将字符串替换与 sprintf 和类似 Razor 的语法结合起来用于流程图
- sql - 在oracle中将具有多行的单列转换为多列
- django - Django 函数包含多个带返回的函数
- google-api - 如果我的 GSuite 帐户被撤销,我如何访问“OAuth 同意屏幕”?
- python - 在熊猫数据框中创建不同变量的滚动总和和平均值
- android-intent - Android API 30 getPackageManager.resolveActivity() 使用 ACTION_VIEW 返回 null
- flutter - Flutter:未处理的异常:NoSuchMethodError:在 null 上调用了 getter 'id'。接收方:null 尝试调用:id
- json - 在 React 中打印这个 JSON 数据的正确结构是什么?
- html - 在按钮 VMware Clarity 上对齐 SVG 图像
- c# - 如何修复 Unity 中函数的数值错误行为?