MUI X - Datagrid - 删除 MuiDataGrid-filler 组件

问题描述 投票:0回答:1

我刚刚注意到网格底部存在额外的填充空间。我怎样才能摆脱它?

enter image description here

变成了这个组件:

enter image description here

我尝试将其高度设置为 0 并删除其边框。但是,当我尝试这样做时,会出现垂直滚动。难道没有更优雅的理由来删除该元素吗?

          "& .MuiDataGrid-filler": {
            height: "0px !important",
            border: "0px solid !important",
          },
material-ui mui-x-data-grid
1个回答
0
投票

MUI 演示页面上的示例 用具有特定高度(如

DataGrid
)的
Box
组件包裹
<Box sx={{ height: 400, width: '100%' }}>

如果删除此包装器

Box
组件或删除其
height
属性,填充 div 将被删除。

您可以查看 this StackBlitz,了解两个数据网格的实时工作示例,一个带有填充物(带

Box
),另一个不带填充物(不带
Box
)。

注意:如果数据网格显示水平滚动,填充物无论如何都会可见。

© www.soinside.com 2019 - 2024. All rights reserved.