I am using primeNg controls in my Angular 8 application.I am using primeng p-table control to show the data. I am using p-dropdown also with p-table. On running my application, it looks like below:
When I click on the dropdown(open dropdown to see the options), it shows only one option like below:
Below is my code:
<p-table>
<ng-template pTemplate="header" let-columns>
<tr class="header-row">
<ng-container *ngFor="let col of columns">
<th
{{col.name}}
</div>
</th>
</ng-container>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr [pSelectableRow]="rowData" class="data-row">
<ng-container *ngFor="let col of columns" [ngSwitch]="col.field">
<td *ngSwitchCase="'app'" classs="ui-resizable-column">
{{rowData[col.field]}}
</td>
<td *ngSwitchCase="'status'" >
<p-dropdown optionLabel="name" [dataKey]="'id'" [(ngModel)]="rowData.selected" [style]="{'width':'100%'}"></p-dropdown>
</td>
</ng-container>
</tr>
</ng-template>
Note: When I have used appendTo="body" with p-dropdown it solves the issue.Like below:
Adding appendTo:
<p-dropdown appendTo="body" optionLabel="name" [dataKey]="'id'" [(ngModel)]="rowData.selected" [style]="{'width':'100%'}"></p-dropdown>
After adding appendTo:
I do not want to use appendTo="body"(due to some reason) to solve the issue. If I am not using appendTo="body" then unable to see all the options of dropdown.