0

I am trying invoke the method when any editable cell value is changed on the primeng p-table. I tried to use onEditComplete event but it will fires only when I edit the cell and press enter. When I edit the cell and move out the mouse it is not firing. Can anyone suggest what is the right event I am supposed to add here?

<p-table [value]="sampleData" [scrollable]="true" scrollHeight="200px" [resizableColumns]="true"
            (onEditComplete)="getLandLineTotal($event)">
            <ng-template pTemplate="header">
                <tr>
                    <th>Col 1</th>
                    <th>Col 2</th>
                    <th>Col 3</th>
                </tr>
            </ng-template>
            <ng-template pTemplate="body" let-rowData>
                <tr>
                    <td style="width: 10%">
                        {{rowData.col1}}
                    </td>
                    <td>
                        {{rowData.col2}}
                    </td>
                    <td pEditableColumn>
                        <p-cellEditor>
                            <ng-template pTemplate="input">
                                <input pInputText type="text" [(ngModel)]="rowData.col3"  required>
                            </ng-template>
                            <ng-template pTemplate="output">
                                {{rowData.col3| currency}}
                            </ng-template>
                        </p-cellEditor>
                    </td>
                </tr>
            </ng-template>
        </p-table>
LilRazi
  • 690
  • 12
  • 33
  • Maybe you could try to add a listener to the cell OnEditInit so it executes getLandLineTotal when it loses the focus. It's a bit of spaghetti but I never used the edit option so I can't give you a proper answer. – Oriol_IL Oct 23 '19 at 08:58

1 Answers1

0

Instead of:

<td pEditableColumn>

Try:

<td [pEditableColumn]="sampleData.col3" [pEditableColumnField]="'col3'">

Developer console should show:

{field: "col3", data: <whatever you entered into the text box>}
Tom
  • 461
  • 1
  • 3
  • 12