禁用单元格编辑器

问题描述 投票:0回答:1

<p-cellEditor style="width: 100%;">
                                <ng-template pTemplate="input">
                                  <p-inputNumber [(ngModel)]="object.amount" name="chargedAmount" mode="currency"
                                    currency="PHP" [disabled]="disableFieldEdit"></p-inputNumber>
                                </ng-template>
                                <ng-template pTemplate="output">
                                  {{ object.amount | currency: 'PHP'}}
                                </ng-template>
</p-cellEditor>

我已经添加了disableFieldEdit,问题是字段显示不可见,因为禁用为灰色。我需要单击该字段才能查看其是否已禁用

angular bootstrap-4
1个回答
0
投票

您无法禁用

p-cellEditor
,您应该使用
ngIf
指令,以便在单元格可编辑的情况下显示
p-cellEditor
,否则您将显示静态单元格

<p-cellEditor style="width: 100%;" *ngIf="canEditCell;else staticCell">
         <ng-template pTemplate="input">
            <p-inputNumber [(ngModel)]="object.amount" name="chargedAmount" mode="currency"
                                    currency="PHP" [disabled]="disableFieldEdit"></p-inputNumber>
         </ng-template>
         <ng-template pTemplate="output">
           {{ object.amount | currency: 'PHP'}}
         </ng-template>
     </p-cellEditor>

<ng-template #staticCell>
    {{ rowData[col.field] }}
</ng-template>
© www.soinside.com 2019 - 2024. All rights reserved.