简体   繁体   English

Fluent UI 读取DetailsList 的视口高度

[英]Fluent UI Reading the height of DetailsList's ViewPort

I'm using DetalisList within ScrollablePane component to keep the header in view, and let the rows scrollable.我在ScrollablePane组件中使用DetalisList来保持标题在视图中,并让行可滚动。 However, this requires me to manually set the height of the scrollable container.但是,这需要我手动设置可滚动容器的高度。

div.scrollable-container
    ScrollablePane
        DetailsList

When I investigate the DOM elements for DetalisList, I can see that it's wrapped inside a ViewPort element.当我调查 DetalisList 的 DOM 元素时,我可以看到它包含在一个 ViewPort 元素中。 The height of this element is the actual height of the sum of the height of all components that make up the list (column headers, rows. etc.).此元素的高度是构成列表的所有组件(列标题、行等)的高度总和的实际高度。 Thus, I want to be able to read this value and set the container height based on whether it exceeds a certain value or not.因此,我希望能够读取此值并根据它是否超过某个值来设置容器高度。

Is there a nice to way to access the height of the ViewPort?有没有一种很好的方法来访问 ViewPort 的高度? I can always query the DOM, and find the element, but I'd like to avoid relying on the internal structure of the component.我总是可以查询 DOM 并找到元素,但我想避免依赖组件的内部结构。

So, far I could not find any information on this.所以,到目前为止我找不到任何关于这方面的信息。 I noticed DetailsList takes a prop called viewport , but I don't think this is what I want.我注意到DetailsList需要一个名为viewport的道具,但我认为这不是我想要的。

You can try by giving height in "vh" (viewport height) unit.您可以尝试以“vh”(视口高度)单位给出高度。 For example,例如,

const gridContainerStyle: IStackStyles = {
   root: { height: "70vh", position: "relative" },
 }; 

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

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