I am trying to adjust the number of rows in my sap.ui.table.Table
to fit the screen height. Initially, I attempted to use
visibleRowCountMode="Auto"
, but it was ineffective because some parent elements lacked a height="100%"
.
The structure of my views involves deep nesting of the table within multiple Page
s and FlexBox
es.
<VBox height="100%" class="sapUiTinyMarginBegin">
<layout:Splitter id="CSL_idSplitter" height="100%" resize=".onSplitterResize">
<VBox height="100%">
<HBox justifyContent="SpaceBetween" height="100%">
<VBox height="100%">
<table:Table id="idTable" visibleRowCountMode="Auto" />
<Button />
</VBox>
</HBox>
</VBox>
</layout:Splitter>
</VBox>
In addition, I included the following CSS snippet:
html, body {
height: 100%;
}
Despite referencing potential solutions from other inquiries, this approach did not resolve the issue for me. Upon inspecting the DOM via Chrome Dev-Tools, I noticed that a directly-parent <div>
of the table-control (implicitly generated by UI5) lacked the necessary style attribute height: 100%
.
https://i.sstatic.net/9ftgC.png
Implementing the height manually on that particular element allowed
visibleRowCountMode="Auto"
to function as intended. However, I consider this workaround unsightly and am seeking a more elegant solution to address this challenge. Currently, upon loading the View
, I programmatically adjust the height of the table's parent <div>
element within the controller's onAfterRendering
method.
onAfterRendering: function() {
const oTable = this.byId("idTable");
const oHTMLElement = document.getElementById(oTable.getIdForLabel());
oHTMLElement.parentNode.style.height = "100%";
}
As this interim fix is far from ideal, I remain open to insights regarding the root cause and a more effective resolution to this issue.