DataGrid 有空组件时如何从列表中删除 "No results found" 标签
How to remove "No results found" label from the list when DataGrid has empty component
const TabbedDatagrid = (props: TabbedDatagridProps) => (
<Datagrid empty={<Empty />}>
<TextField source="id" />
<TextField source="createDate" />
</Datagrid>
);
const Empty = () => {
const { basePath } = useListContext();
return (
<Box textAlign="center" m={1}>
<Typography variant="h4" paragraph>
No products available
</Typography>
<Typography variant="body1">
Create one or import from a file
</Typography>
<CreateButton basePath={basePath} />
<Button>Import</Button>
</Box>
);
};
const MyList = (props: ListProps) => (
<List
{...props}
sort={{ field: 'createDate', order: 'DESC' }}
perPage={10}
filters={orderFilters}
pagination={<PostPagination />}
>
<TabbedDatagrid />
</List>
);
结果中都显示了“未找到结果”和空组件
如何只显示空组件?
您可以将这些消息替换为您的:Translating The Empty Page
组件采用 limit
属性。
limit: An element that is displayed if there is no data to show (default: <PaginationLimit>)
您可以尝试传递 null <PostPagination limit={null} />
来隐藏默认的“未找到结果”消息。
const TabbedDatagrid = (props: TabbedDatagridProps) => (
<Datagrid empty={<Empty />}>
<TextField source="id" />
<TextField source="createDate" />
</Datagrid>
);
const Empty = () => {
const { basePath } = useListContext();
return (
<Box textAlign="center" m={1}>
<Typography variant="h4" paragraph>
No products available
</Typography>
<Typography variant="body1">
Create one or import from a file
</Typography>
<CreateButton basePath={basePath} />
<Button>Import</Button>
</Box>
);
};
const MyList = (props: ListProps) => (
<List
{...props}
sort={{ field: 'createDate', order: 'DESC' }}
perPage={10}
filters={orderFilters}
pagination={<PostPagination />}
>
<TabbedDatagrid />
</List>
);
结果中都显示了“未找到结果”和空组件 如何只显示空组件?
您可以将这些消息替换为您的:Translating The Empty Page
limit
属性。
limit: An element that is displayed if there is no data to show (default: <PaginationLimit>)
您可以尝试传递 null <PostPagination limit={null} />
来隐藏默认的“未找到结果”消息。