I want create a new editable row by default when clicking "ADD NEW button". like below screen shot. When I click "+" button a new row will create. once I edit that row and click "done" button the new row will submit.
I have tries below code. a new row created but without editable option.
See below screen shot. I want create a new editable row when clicking add new button.
addNew() {
let newData: IStoreStaffDesignation = {
storeStaffDesignationId: '2',
schoolBaseCode: '',
code: '',
name: '',
description: '',
nameTamil: '',
nameSinhala: '',
sortOrder: 0,
appUserBaseId: ''
};
this.storeStaffDesignations.unshift(newData);
//TODO : call api
}
<p-table #dt1 [value]="storeStaffDesignations" [rowHover]="true" [paginator]="true" [rows]="10" [showCurrentPageReport]="true"
responsiveLayout="scroll" [resizableColumns]="true"
[lazy]="true" (onLazyLoad)="lazyLoadHandler($event)" [loading]="loading"
currentPageReportTemplate="Showing {{first}} to {{last}} of {{totalRecords}} entries"
[rowsPerPageOptions]="[10, 25, 50]" editMode="row" dataKey="storeStaffDesignationId"
[globalFilterFields]="['code', 'name', 'description']" [(selection)]="selectedStoreStaffDesignation"
styleClass="p-datatable-striped p-datatable-gridlines"
>
// header template removed
// body
<ng-template pTemplate="body" let-storeStaffDesignation let-editing="editing" let-ri="rowIndex">
<tr [pEditableRow]="storeStaffDesignation" style="height: 1rem" [class]="'storeStaffDesignation' +storeStaffDesignation.storeStaffDesignationId">
// td tag removed
</tr>
// rest of the rows
</ng-template >
</ptable>
Anyone has a example for this