reactjs - 在 MUI DataGrid 中应用过滤器后显示“无行”消息
问题描述
NoRowsOverlay
应用过滤器后不起作用,因此没有/没有要显示的行。
这是我的代码:
function customNoRowsOverlay() {
return (
<GridOverlay>
<div>No Rows</div>
</GridOverlay>
)
}
components={{ NoRowsOverlay: customNoRowsOverlay }}
如果在应用过滤器后没有/没有要显示的行,我需要显示“无行”消息。但是,如果您有上述代码,则可以使用rows={[]}
解决方案
NoRowsOverlay
如果您使用的是@v4.0.0-alpha.18 或更高版本,请使用插槽名称。
如果您想在 中没有行时显示覆盖,您可以根据您的用例DataGrid
覆盖NoRowsOverlay
或插入:NoResultsOverlay
NoRowsOverlay
: 当没有行传递给DataGrid
(rows={[]}
) 时显示。NoResultsOverlay
: 有行数据时显示DataGrid
,但本地过滤器没有返回结果。
<DataGrid
{...}
components={{
NoRowsOverlay: () => (
<Stack height="100%" alignItems="center" justifyContent="center">
No rows in DataGrid
</Stack>
),
NoResultsOverlay: () => (
<Stack height="100%" alignItems="center" justifyContent="center">
Local filter returns no result
</Stack>
)
}}
/>
现场演示
推荐阅读
- node.js - 获取引用的路径属性
- python - Python将模块移动到子目录(不破坏现有的导入结构)
- mysql - 通过 sql 计算用户看到的唯一项目
- java - 当您距离标记点不到 10 米时,如何开始一些方法?
- python - 使用 xlsxwriter 将一维 numpy 数组写入 excel
- java - 线程“主”org.apache.spark.sql.catalyst.parser.ParseException 中的异常
- javascript - 当用户 (A) 使用 Firebase 云功能和 Flutter 关注用户 (B) 时如何接收通知
- r - 使用 R DBI 包插入到
- ios - 在 swift 中使用 fscalendar 从 API 响应中获取事件的值
- spring-cloud-stream - 是否实现基于任务或流的方法