admin管理员组文章数量:1296310
I have a React project in which Material Table 1.69.3 is being used. It is passed in the components for the body a render function for virtualized rows. This function splices the data, and then renders
<TableBody>
<MTableBodyRow {…props}/>
</TableBody>
this component is passed on a conditional. When false the table is good, all rows are aligned with the headers w/ some columns set to hidden. scrolling works well, and the table allows itself to be cut off when the window is resized.
The problem is when the conditional is true, and columns are hidden, as immediately the rows and remaining column headers do not line up.
First solution I had was my <tr>
had the styles
position:absolute
translateY: ${75*i}
which removing fixed the unalignment, but made the virtualization bug out, and scrolling the table would make the scroll jump around.
second solution was simple one of pass the width in the rowData of the columns by
const visibleColumns = this.props. columns.filter(column => !column.hidden)
const columnWidths = “calc(this.state.tableWidth / visibleColumns.length)”
and passed in columnWidth. This however depends on tableWidth which is changed when the window is resized. Making for if the table is resized/cut off all the rows will squish on screen while the columns remain in their original position.
If the original render value of tableWidth is saved and only used, then the table cant be expanded, if opened in a smaller window at first.
So to reiterate, my main problem is that when columns are hidden, the rows of my MaterialTable do not line up with the above column headers. Only occurs when custom component body is passed in, when not table works perfectly.
Sadly this is a problem I’m having at work so cannot copy any code, bit shown from memory.
本文标签: cssHow to keep rows aligned with column headers when hiding columns on Material TableStack Overflow
版权声明:本文标题:css - How to keep rows aligned with column headers when hiding columns on Material Table - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741620799a2388797.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论