我已经设置了我的react管理员来连接到我的nestJS后端。对于简单的API,一切都很好,我能够正确执行CRUD。问题出现在下面这样的情况下。
我有这样的表定义
Pages table
Section table(foreign key -> pageId) - corresponds to the id in pages table
Widget table(foreign key -> sectionId) - corresponds to id in section table
我想以数据表格的形式加载页面,并且在点击某一行时,我应该能够以数据表格的形式获得所需的部分。一旦我有了部分,我应该能够在点击任何部分的行时获得部件。同时,我应该能够在每个数据表格上执行CRUD操作。
POST请求的例子如下。
for pages - >http://localhost:3010/config/pages
sections - http://localhost:3010/config/pages/:pageId/sections
widgets - http://localhost:3010/config/pages/:pageId/sections/:sectionId/widgets
请帮助我
我认为你可以创建一个 显示-您的组件 Page
-记录有: 参考多字段 内。Datagrid
可为 ReferenceManyField
. 所以这看起来就像这样。
<ReferenceManyField
{...props}
reference="sections"
target="pageId">
<Datagrid label="Sections">
<TextField source="id"/>
[...]
</Datagrid>
</ReferenceManyField>
或者,当你点击一个页面行时,你可以链接到主节列表,并应用一个过滤器,这样就只显示特定页面ID的节,例如,通过链接到 /#/sections?displayedFilters={"pageId":true}&filter={"pageId":123}
. 这就需要你在下面设置相应的过滤器ui。List
-组成部分。