[ant-design]Table虚拟化,scroll.x横向区域列宽问题

2023-12-14 582 views
2

https://ant-design.antgroup.com/components/table-cn#scroll

虚拟列表与普通列表的scroll属性表现完全不一致 1.开启虚拟化,有的列不设width是为了适应弹性布局,但是虚拟列表必须配置scroll.x,导致需要根据每列宽度计算scroll.x,而无宽度列无法计算,也无法做到适应剩余空间 2.开启虚拟化,固定列的宽度会根据scroll.x计算,做不到固定宽度

尽量做到虚拟列表与普通列表的scroll属性表现一致

Environment Info
antd 5.9.4
React 18.2.0
System win11
Browser 117.0.5938.92

回答

0

给个重现看看你的配置~

7

Hello @cjtcjt999. Please provide a online reproduction by forking codesandbox of antd@5.x or antd@4.x, or provide a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @cjtcjt999, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击这里创建一个 antd@5.xantd@4.x 的 codesandbox,或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

6

发在 7.35.2 上,下个 feature 会带上哈~

0

scroll 有大问题 当 不给table设置宽度时 使用scroll属性会报Cannot read properties of null (reading 'querySelector')问题

6

不对设了宽度也会报这个问题,具体来自这段代码 function useContainerWidth(prefixCls) { const getContainerWidth = (ele, width) => { const container = ele.querySelector(.${prefixCls}-container); let returnWidth = width; if (container) { const style = getComputedStyle(container); const borderLeft = parseInt(style.borderLeftWidth, 10); const borderRight = parseInt(style.borderRightWidth, 10); returnWidth = width - borderLeft - borderRight; } return returnWidth; }; return getContainerWidth; }