简体   繁体   English

如何通过调整大小功能使 ag 网格标题具有粘性和响应性

[英]How to make ag grid header sticky and responsive with resizing feature

Resolved: (100 % working in chrome and edge) (in IE11, it works fine if there is no horizontal scroll in grid)已解决: (100% 在 chrome 和 edge 中工作)(在 IE11 中,如果网格中没有水平滚动,它工作正常)

HTML: gridAutoHeight = true in ag-grid-angular html tag HTML: gridAutoHeight = true in ag-grid-angular html 标签

TS: window.addEventListener('scroll', this.scroll); TS: window.addEventListener('scroll', this.scroll); in ngOnit()在 ngOnit() 中

scroll = (event: any): void => {
let headerElementRef;
let bodyElementRef;
headerElementRef = document.querySelector('[ref="headerRoot"]');
bodyElementRef = document.querySelector('[ref="eBodyViewport"]');
const nav = headerElementRef;
const body = bodyElementRef;
const offset = nav.getBoundingClientRect();
if (!nav) return;

  if (window.pageYOffset > offset.top && !(body.getBoundingClientRect().top - nav.getBoundingClientRect().height > 0)) {
    nav.style.position = 'fixed';
    nav.style.top = 0;
    nav.style.zIndex = "2";
    nav.style.width = this.totalGridWidth + 'px';
  } else {
    nav.style.position = 'relative';
    nav.style.top = '';
    nav.style.zIndex = "";
    nav.style.width = this.totalGridWidth + 'px';
  }

} }

Try below code:试试下面的代码:

<div class="table-responsive">
  <ag-grid-angular style="margin-top:10px; width: 100%; height: 200px;" class="ag-theme-balham" [pagination]="true" [paginationPageSize]="paginationPageSize" [enableColResize]="true" [paginationNumberFormatter]="paginationNumberFormatter" [enableSorting]="true" [enableFilter]="true" [headerHeight] = "headerHeight" [gridAutoHeight] = "true" [overlayNoRowsTemplate]="overlayNoRowsTemplate" [rowData]="gridData" [columnDefs]="columnDefs" (columnResized)="onColumnResized($event)" (gridReady)="onGridReady($event)" (rowClicked)="onRowClicked($event)"> </ag-grid-angular>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM