I konw primeNG use
let-editing="editing"
<button *ngIf="!editing" pButton pRipple type="button" pInitEditableRow icon="pi pi-pencil" (click)="onRowEditInit(product)" class="p-button-rounded p-button-text"></button>
<button *ngIf="editing" pButton pRipple type="button" pSaveEditableRow icon="pi pi-check" (click)="onRowEditSave(product)" class="p-button-rounded p-button-text p-button-success mr-2"></button>
<button *ngIf="editing" pButton pRipple type="button" pCancelEditableRow icon="pi pi-times" (click)="onRowEditCancel(product, ri)" class="p-button-rounded p-button-text p-button-danger"></button>
to do something.
but how can I accomplish what I need as the title.
<td style='width: 160px;' pCancelEditableRow>
{{field.fName}}
</td>
I tried add the top code to do some crude thing.
Here is the code to achieve the desired behavior of exiting row edit when clicking on another line in a PrimeNG table:
In this code, I've made a few modifications to your existing code. The key change is that I've added a condition
rowIndex !== editingRowIndexto the "Save" and "Cancel" buttons in each row. This condition ensures that the buttons to save or cancel editing are only shown when the current row being edited is not the same as the row you are clicking on. This way, clicking on another line will exit the editing mode of the previous row. TheeditingRowIndexvariable is used to keep track of the row currently being edited.