简体   繁体   English

如果未找到数据,ag-grid 将隐藏列标题下方的所有内容

[英]ag-grid hiding everything below column headers if no data found

When I use ag-grid of given fixed height with Angular, before any data is shown the space where data will be shown (so grid in fact) is visible with text 'loading'.当我在 Angular 中使用给定固定高度的 ag-grid 时,在显示任何数据之前,将显示数据的空间(实际上是网格)在文本“加载”中可见。 It's not correct in my case, as I don't bind rowData to Observable or Promise so it's not async.在我的情况下这是不正确的,因为我没有将 rowData 绑定到 Observable 或 Promise 所以它不是异步的。 The grid is populated after click on button.单击按钮后将填充网格。 I'd like to see only column headers and nothing below that.我只想看到列标题,而没有列标题。 My grid config looks like that:我的网格配置如下所示:

<ag-grid-angular
style="width: 100%; height: 335px;"
class="ag-theme-balham"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
animateRows
rowSelection="multiple"
>

So I'd like to hide whole grid except of column headers until rowData is empty array.所以我想隐藏除列标题之外的整个网格,直到 rowData 为空数组。 Is there a way to do this?有没有办法做到这一点?

Just to clarify, I use ag-grid with React but there are many similarities between the two.为了澄清起见,我将 ag-grid 与 React 一起使用,但两者之间有许多相似之处。 There are two things you can do here:您可以在这里做两件事:

  1. You can control what text is visible while loading or if there is no data with您可以控制加载时哪些文本是可见的,或者如果没有数据
    [overlayLoadingTemplate]="<span></span>"
    [overlayNoRowsTemplate]="<span></span>"
  1. Since you are currently setting a fixed height in your in line styling for the grid, it will always be at 335px.由于您当前正在为网格的内嵌样式设置固定高度,因此它始终为 335 像素。 Once you set that to something that's not static, you can add this prop to the grid and it will change the height of the grid depending on data inside.一旦你将它设置为非静态的东西,你就可以将这个道具添加到网格中,它会根据里面的数据改变网格的高度。
[domLayout]="autoHeight"

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

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