使用 `admin-on-rest` 显示嵌套数据

Display nested data using `admin-on-rest`

我有以下格式的数据 -

{
  "categories": [
  {
    "id": "1",
    "code": "TESTCODE001",
    "name": "TESTCODE001",
  "subcategories": [
    {
      "id": "11",
      "code": "TESTCODE0002",
      "name": "TESTCODE0002",
      "subcategories": []
    }
  ]
}

我无法显示子类别。我试过使用 ReferenceArrayField 但我无法使用它,因为类别和子类别是从同一个 API 中获取的。还尝试使用自定义组件来显示子类别,这也是不可能的,因为当我单击子类别时它会显示编辑表单。

我写的代码- categories.js

export const CategoryList = (props) => (
    <List title="All categories"  {...props} >
        <Datagrid>
             <TextField source="code" />
             <TextField source="name" />
             <TextField source="id" />
             <LinkToRelatedSubcategories/>
             <EditButton />
        </Datagrid>
     </List>
);

LinkToRelatedSubcategories.js

const LinkToRelatedSubcategories = ({ record, translate }) => (
    <FlatButton
        primary
        label='Subcategories'

        containerElement={<Link params={{ testvalue: "hello" }}
            to={{
                pathname: '/category/categoryId',

            }}
        />}
    />
);

任何帮助将不胜感激。

this is also not possible as it shows the edit form when I click on subcategories.

对于展示页面,您可以使用:/category/categoryId/show

也许你可以使用 react-admin instead of admin-on-rest. Its the new version, now in release candidate mode. It has https://marmelab.com/react-admin/Fields.html#arrayfield and https://marmelab.com/react-admin/Inputs.html#arrayinput