Below is the code for the column in the datatable
<p-column field="organization.description" header="Partner" [editable]="dtCostShare" [style]="{'width':'30%'}">
<ng-template let-col let-csp="rowData" pTemplate="editor">
<span class="required-lbl">* <p-dropdown name="organization" [(ngModel)]="csp.organization.organizationId" (onChange)="addPartnerDescription(csp.index)" [options]="partners" [style]="{'width':'10px'}" appendTo="body" [ngClass]="{'errorCol':csp.organization.organizationId === ''}">
</p-dropdown>
</span>
<span *ngIf="(csp.organization.organizationId === '' )" class="text-danger">Partner is required</span>
</ng-template> </p-column>
ts code to populate the droupdown
getPartners() {
this.partners.push({ label: 'Please Select', value: '' });
this.parameterService.getPartners().subscribe((data) => {
for (let record of data) {
this.partners.push({ label: record.description, value: record.organizationId });
}
});
}
Whenever i edit the grid the dropdown shows the "Please select" instead of showing the selected Organization name. When i print the "csp.organization.organizationId" it is giving the selected organizationId but [(ngModel)] doesn't seem to set the selected value.
where am i going wrong?