Angular: 编辑单元格事件 PrimeNG TreeTable 的调用方法
Angular: Call method on edit cell event PrimeNG TreeTable
我有一个 PrimeNG TreeTable,其中有一个可编辑的列 数量
cart.html
<p-treeTable [value]="items" [columns]="cols">
<ng-template pTemplate="body" let-rowNode let-rowData="rowData">
<tr>
<td [ttEditableColumn]="rowData.quantity" [ttEditableColumnField] = "quantity">
<p-treeTableToggler [rowNode]="rowNode"></p-treeTableToggler>
<p-treeTableCellEditor>
<ng-template pTemplate="input" >
<input type="text" [(ngModel)]="quantity">
</ng-template>
<ng-template pTemplate="output" >
{{quantity}}
</ng-template>
</p-treeTableCellEditor>
</td>
</tr>
</ng-template>
</p-treeTable>
如何在编辑单元格(按下 Enter)后调用方法 onEdit()?
你应该使用
<p-treeTable [value]="items" [columns]="cols" (onEditComplete)="onEdit(event)">
哪里
onEdit(event: { field: string, data: any }): void {
// your code
}
我有一个 PrimeNG TreeTable,其中有一个可编辑的列 数量
cart.html
<p-treeTable [value]="items" [columns]="cols">
<ng-template pTemplate="body" let-rowNode let-rowData="rowData">
<tr>
<td [ttEditableColumn]="rowData.quantity" [ttEditableColumnField] = "quantity">
<p-treeTableToggler [rowNode]="rowNode"></p-treeTableToggler>
<p-treeTableCellEditor>
<ng-template pTemplate="input" >
<input type="text" [(ngModel)]="quantity">
</ng-template>
<ng-template pTemplate="output" >
{{quantity}}
</ng-template>
</p-treeTableCellEditor>
</td>
</tr>
</ng-template>
</p-treeTable>
如何在编辑单元格(按下 Enter)后调用方法 onEdit()?
你应该使用
<p-treeTable [value]="items" [columns]="cols" (onEditComplete)="onEdit(event)">
哪里
onEdit(event: { field: string, data: any }): void {
// your code
}