如何使用公共变量/数据访问 ag-grid 的 bodyHeight 属性?
我在 ag-grid 社区有一个项目 React。它具有一个可滚动部分,其中填充了我们的数据。我们可能只有一条数据,也可能有一百万条数据。我还为该网格渲染一个页脚组件,其高度必须根据 bodyHeight 属性而变化。
目前,我发现执行此操作的唯一方法是访问行节点上的私有属性 gridApi。这不是我希望使用的模式。有没有更好的方法来访问 ag-grid 的可滚动高度?
I have a project in ag-grid community react. It features a scrollable section that is populated with our data. We might have just one piece of data, we might have a million pieces of data. I'm also rendering a footer component for that grid, and its height must vary based on the bodyHeight property.
Presently, the only way I've found to do this is to access a private property, gridApi, on row nodes. This is not a pattern that I wish to use. Is there a better way of accessing the scrollable height of the ag-grid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用公共记录的 API 访问 bodyHeight,您必须通过 Grid API 内部方法/属性来访问它,正如您所说,这对您来说不是一个理想的解决方案。
唯一的其他选择是将 DOM 元素定位为视口:
如果您有一行数据,则网格内可能有很多空白空间,您可以使用 网格自动高度 告诉网格根据数据。
You can't access the bodyHeight using public documented APIs, you'd have to access it via the Grid API internal methods/properties, which as you said is not an ideal solution for you.
The only other option would be to target the DOM element for the Viewport:
If you have one row of data, you'll probably have a lot of empty space inside the grid, you could use Grid Auto Height to tell the grid to auto-size it's height based on the data.