我有一个包含department的building资源。当我单击部门芯片时,我想要编辑部门。目前,在GET /building上,我的接口返回如下数据:
[
{
"id": 1,
"name": "Building 1",
"departments: [
{"id": 1, "name": "Department 1"},
{"id": 1, "name": "Department 1"}
]
}
]在列出建筑物时,我可以使用下面的代码将部门作为ChipField。但是当我点击部门芯片时,我想不出打开部门编辑表单的方法。
export const BuildingList = (props) => (
<List {...props}>
<Datagrid rowClick="edit">
<TextField source="id" />
<TextField source="title" />
<ArrayField source="departments">
<SingleFieldList>
<ChipField source="name"/>
</SingleFieldList>
</ArrayField>
</Datagrid>
</List>
}

目前,点击部门会打开像http://localhost:5000/api/building/%7B%22id%22:108,%22name%22:%22Dept.%20of%20Computer%20Science%22,%22url%22:%22http://www.southeastern.edu/acad_research/depts/comp_sci/%22,%22phone%22:%22985-549-2189%22,%22email%22:null,%22description%22:null,%22keywords%22:null,%22buildingId%22:1%7D这样的网址
这意味着React-Admin认为这是一座大楼,而不是一个部门。你有什么办法让它工作起来吗?谢谢。
这是要显示的BulidingList
发布于 2020-08-27 02:02:34
我刚刚遇到了同样的问题。虽然显然没有文档记录,但<ArrayField>将basePath视为一种属性。
虽然没有使用您的数据进行测试,但假设departments也是一个react-admin资源,这样的东西可能对您有效。这似乎配置了为ChipField自动创建的链接。除了指定basePath之外,我还指定了fieldKey,即documented。
<ArrayField basePath="/departments" source="departments" fieldKey="id">
<SingleFieldList>
<ChipField source="name" />
</SingleFieldList>
</ArrayField>https://stackoverflow.com/questions/58759554
复制相似问题