我想渲染一个没有任何垂直滚动条的材质 UI 数据网格。这是网格的代码:
return <div style={{height: 400, width: '100%', } }>
<DataGrid className={classes.root} rows={closedPositions} columns={columns} rowHeight={20}
headerHeight={25} disableSelectionOnClick pageSize={20} autoPageSize={true} scrollbarSize={1}
components={{
pagination: CustomPagination,
}}
/>
autopageSize 的文档是:
If true, the pageSize is calculated according to the container size and the max number of rows to avoid rendering a vertical scroll bar.
因此我很困惑为什么我有一个滚动条。即使我将 div 设置为高度 10,000 且表格中没有行,我仍然会得到一个滚动条。
此外,scrollbarSize 为 15 和 1 之间没有区别(对于我想要的水平滚动条)。
有人知道出了什么问题吗?
答案 0 :(得分:1)
你试试下面的代码?
autoHeight={true}
它对我来说很好。
示例。
<div style={{ width: "100%" }}>
<DataGrid
rows={rows}
columns={columns}
autoHeight={true}
/>
</div>