I am working with a primeng table that allows for editing rows by clicking on the pInitEditableRow
button. However, I would like to initiate row editing by double-clicking on the row or any cell within that row. Unfortunately, Primeng table does not have this functionality built-in like it does with buttons. Is there a way to achieve this? Essentially, I want to trigger the same action as the pInitEditableRow
button click when I double-click on the corresponding row.
<p-table [value]="products" dataKey="id" editMode="row" [tableStyle]="{'min-width': '50rem'}">
<ng-template #header>
<tr>
<th style="width:20%">Name</th>
</tr>
</ng-template>
<ng-template #body let-product let-editing="editing" let-ri="rowIndex">
<tr [pEditableRow]="product">
<td>
<p-cellEditor>
<ng-template #input>
<input
pInputText type="text"
[(ngModel)]="product.name"
required />
</ng-template>
<ng-template #output>
{{product.name}}
</ng-template>
</p-cellEditor>
</td>
<td>
<div class="flex items-center justify-center gap-2">
<button
*ngIf="!editing"
pButton
pRipple
type="button"
pInitEditableRow
icon="pi pi-pencil"
(click)="onRowEditInit(product)"
text
rounded
severity="secondary"
></button>
<button
*ngIf="editing"
pButton
pRipple
type="button"
pSaveEditableRow
icon="pi pi-check"
(click)="onRowEditSave(product)"
text
rounded
severity="secondary"
></button>
<button
*ngIf="editing"
pButton
pRipple
type="button"
pCancelEditableRow
icon="pi pi-times"
(click)="onRowEditCancel(product, ri)"
text
rounded
severity="secondary"
></button>
</div>
</td>
</tr>
</ng-template>
</p-table>