Primeng: OverlayPanel display position on the page top not related to the div

Created on 29 Nov 2017  路  5Comments  路  Source: primefaces/primeng

I am using the OverlayPanelModule in my application, always the panel display the bottom of the page. not on the proper position.

<p-dataTable class="backLogChanges"  scrollable="true"   [value]="changes" [rows]="10" [paginator]="true" [pageLinks]="3" [rowsPerPageOptions]="[5,10,20]" [sortMode]="single" resizableColumns="true" columnResizeMode="expand" tableStyleClass="table-hover" [globalFilter]="gb" (onFilter)="onFilter($event)" *ngIf="!loading"
    [attr.sortField]="defaultSortField()" [sortOrder]="-1" #dt>

        <p-column *ngFor="let col of cols" [field]="col.field" [header]="col.header" [sortable]="col.sortable" [filterMatchMode]="col.filterMatchMode" [filter]="col.filter" [style]="col.width?{'width': col.width+'px'}:''">
          <ng-template let-column let-change="rowData" pTemplate="body">
<span (mouseenter)="op2.show($event)">{{ change[column.field] | slice:0:64 }}</span>
</ng-template>
        </p-column>
    </p-dataTable>
<p-overlayPanel #op2 [dismissable]="true" [showCloseIcon]="true">
    Testing
</p-overlayPanel> 

Most helpful comment

after setting appendTo property working fine.

<p-overlayPanel #op2 [dismissable]="true" [showCloseIcon]="true" [appendTo]="'body'">
        Testing
    </p-overlayPanel>

All 5 comments

after setting appendTo property working fine.

<p-overlayPanel #op2 [dismissable]="true" [showCloseIcon]="true" [appendTo]="'body'">
        Testing
    </p-overlayPanel>

Glad to hear.

I had a similar situation with @govindarajkp. In the documentation it's null. Shouldn't there be a default value for [appendTo]?

I fixed this by creating a div element with a certain size, and using that as the target when opening the overlay.

<div
  #overlayTarget
  style="width: 200px; height: 30px; margin-top: -30px;"
></div>
export class MyComponent {
  @ViewChild('overlayTarget')
  overlayTarget: ElementRef;

  @ViewChild('myDialog')
  myDialog: OverlayPanel;

  @HostListener('click', ['$event'])
  onClick(event: MouseEvent) {
    this.myDialog.show(event, this.overlayTarget.nativeElement);
  }
}

after setting appendTo property working fine.

<p-overlayPanel #op2 [dismissable]="true" [showCloseIcon]="true" [appendTo]="'body'">
      Testing
  </p-overlayPanel>

it worked for me but in this other way in Angular

<p-overlayPanel #op2 [dismissable]="true" [showCloseIcon]="true" appendTo="body">
       Testing
</p-overlayPanel>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

just-paja picture just-paja  路  3Comments

garethlewis picture garethlewis  路  3Comments

SchneMa picture SchneMa  路  3Comments

lilling picture lilling  路  3Comments

watalberto picture watalberto  路  3Comments