I am using Primeng p-table control in my angular 7 application. Below is the html code I am using:
<p-table [value]="data" [reorderableColumns]="'true'" [columns]="cols">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns" pReorderableColumn>
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr>
<td [pEditableColumn] *ngFor="let col of columns" [ngSwitch]="col.field">
<p-cellEditor *ngSwitchCase="'TYPE'">
<ng-template pTemplate="output">
{{rowData[col.field]}}
</ng-template>
</p-cellEditor>
<p-cellEditor *ngSwitchCase="'CEPCODE'">
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="rowData[col.field]" required>
</ng-template>
<ng-template pTemplate="output">
{{rowData[col.field]}}
</ng-template>
</p-cellEditor>
<p-cellEditor *ngSwitchCase="'HRS'">
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="rowData[col.field]" required>
</ng-template>
<ng-template pTemplate="output">
{{rowData[col.field]}}
</ng-template>
</p-cellEditor>
</td>
</tr>
</ng-template>
On Running application table looks like below:
In my above table Type column is not editable and all other columns are editable. I want to know how we can set [pEditableColumn] for td dynamically(if column is type then do not set [pEditableColumn])