I am looking for a way to allow Show to be able to use a Datagrid on the show page. I want to be able to click on the show button and when the show page appears, I want to be able to take data and make another grid using Datagrid or something similar. Any Ideas how this is done?
问问题
101 次
1 回答
2
似乎显示页面需要 1 条记录并呈现它。在显示页面上,您可以放置与当前相关的记录。例如news
可以与一个project
和一个project
有很多有关news
。下面的代码从 api 获取所有相关news
并将其呈现为表格。希望对你有帮助
export const ProjectShow = ({ ...props }) => (
<Show title={<ProjectTitle />} {...props}>
<SimpleShowLayout>
<ReferenceManyField label="News" reference="news" target="project_id">
<Datagrid>
<TextField source="id" />
<TextField source="title" />
<DateField source="created_at" showTime />
<DateField source="updated_at" showTime />
<EditButton />
</Datagrid>
</ReferenceManyField>
</SimpleShowLayout>
</Show>
);
不记得 App.js 行中的位置:
<Resource name="projects" ...another actions... show={ProjectShow} />
于 2017-05-25T10:29:50.347 回答