2

how to show or hide edit button based when column srcSysName value = "ANO" in p-table

Here is the code

<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>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
xrx215
  • 747
  • 6
  • 22
  • 38

2 Answers2

0

Can you please add *ngIf="ACC_LIST.srcSysName === 'ANO'" in your edit button?

<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>
Aman Gojariya
  • 1,289
  • 1
  • 9
  • 21
0
<td style="text-align:center">
    <button *ngIf="ACC_LIST.shortName === 'ANO'"  pButton pRipple type="button" pInitEditableRow icon="pi pi-pencil" (click)="onRowEditInit()" class="p-button-rounded p-button-text"></button>                
</td>
Viral Patel
  • 1,104
  • 4
  • 7