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

标签 html css typescript angular6 ag-grid-angular

已解决:(100% 在 chrome 和 edge 中工作)(在 IE11 中,如果网格中没有水平滚动则工作正常)

HTML: ag-grid-angular html 标签中的 gridAutoHeight = true

TS: window.addEventListener('滚动', this.scroll);在 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';
  }

最佳答案

试试下面的代码:

<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>

关于html - 如何通过调整大小功能使 ag 网格标题具有粘性和响应性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55689158/

相关文章:

javascript - Angular 4 路由奇怪的行为 : not rendering child module unless on page refresh

javascript - 如何使用javascript给一个div标签一个唯一的id

html - 不需要按部分属性选择?

html - CSS 变换旋转动画不适用于 Firefox 中的 anchor 元素

javascript - 如何阻止表单在提交时重置

html - 带有叠加列的两列布局 - 此处是否可以使用 flexbox 还是我需要解决显示 : inline-block?

html - 风格不适用

node.js - 如何在 Node 中的函数调用中等待回调?

jquery - 从matrix3d获取CSS3旋转周期数

typescript - 如何在 typescript 中的 React Native 中设置全局变量?