方法 1:(简单)
将 showCellRightBorder={true}
添加到您的 Datagrid
组件中
方法 2:(提供定制)
将以下 CSS 添加到您的 Datagrid
组件的 sx
属性中。
CODE TO BE REMOVED:
// "& .MuiDataGrid-row": {
// borderTop: 1,
// borderBottom: 0
// },
CODE TO BE ADDED:
"& .MuiDataGrid-cell": {
border: 1,
borderRight: 0,
borderTop: 0,
// add more css for customization
},
数据网格自动将行宽度设置为“适合内容”,这会剪裁右侧边框。要解决此问题,您只需要使用“& .MuiDataGrid-row”全局类手动设置行的宽度为所需大小即可。在我的情况下,它看起来像:
"& .MuiDataGrid-row": {
border: "1px solid lightgray",
borderRadius: "5px",
backgroundColor: "white",
width: "calc(100% - 2px)",
marginTop: 3
},