angular - 如何根据 p 表中的列值显示或隐藏编辑按钮
问题描述
当 p 表中的列 srcSysName 值 =“ANO”时,如何显示或隐藏编辑按钮
这是代码
<ng-template pTemplate="body" let-ACC_LIST let-editing="editing" let-ri="rowIndex">
<tr [pEditableRow]="ACC_LIST">
<td>
{{ACC_LIST.accntNum}}
</td>
<td>
<p-cellEditor>
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="ACC_LIST.shortName">
</ng-template>
<ng-template pTemplate="output">
{{ACC_LIST.shortName}}
</ng-template>
</p-cellEditor>
</td>
<td>{{ACC_LIST.srcSysName}}</td>
<td style="text-align:center">
<button *ngIf="!editing" pButton pRipple type="button" pInitEditableRow icon="pi pi-pencil"
(click)="onRowEditInit()" class="p-button-rounded p-button-text"></button>
</td>
</tr>
</ng-template>
解决方案
您能否在您的编辑按钮中添加 * ngIf="ACC_LIST.srcSysName === 'ANO'" ?
<ng-template pTemplate="body" let-ACC_LIST let-editing="editing" let-ri="rowIndex">
<tr [pEditableRow]="ACC_LIST">
<td>{{ACC_LIST.accntNum}}</td>
<td>
<p-cellEditor>
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="ACC_LIST.shortName" />
</ng-template>
<ng-template pTemplate="output"> {{ACC_LIST.shortName}} </ng-template>
</p-cellEditor>
</td>
<td>{{ACC_LIST.srcSysName}}</td>
<td style="text-align: center">
<button *ngIf="ACC_LIST.srcSysName === 'ANO'" pButton pRipple type="button" pInitEditableRow icon="pi pi-pencil" (click)="onRowEditInit()" class="p-button-rounded p-button-text"></button>
</td>
</tr>
</ng-template>
推荐阅读
- gcc - Xlc '-qthreaded' 编译器选项的 gcc 等效项是什么?
- android - Android:如何在活动上方显示透明加载层
- javascript - Visual Studio ReSharper - 在外部模块中声明的 Typescript 自动导入类 - 使用 from 而不是 require
- java - Java Hyperledger-panic:runtimr 错误:无效的内存地址或 nil 指针取消引用
- django - 基于 django 类的视图是否继承 method_decorators?
- oracle - 我不知道我的 SQL 有什么问题(在 Oracle SQL Developer 中)
- python - 无法使用 Scrapy 抓取下一页内容
- c# - WinForms NumericUpDown 不断乘以 10。为什么?
- php - 适用于 Web 应用程序的 Azure MySQL In App 不更新行
- javascript - 没有标签的html文本