【问题标题】:Custom URL for ShowButton on admin-on-restadmin-on-rest 上 ShowButton 的自定义 URL
【发布时间】:2018-02-05 15:41:35
【问题描述】:

有没有办法为某些显示按钮制作自定义路径?

我有一个ReferecenManyField,它下面有两种类型的组件,我想重定向到每个组件的显示页面。

在我的CollectionShow 我有

<Show title={<CollectionTitle />} actions={<CollectionShowActions />} {...props}>
  <SimpleShowLayout>
  ...

  <ReferenceManyField label="Itens" target="collection_id" reference="collection_items">
    <Datagrid bodyOptions={{ showRowHover: true }}>
       <TextField source="id" />
       <TextField label="Tipo" source="collectionable_type" />
       <TextField label="Nome" source="collectionable.name" sortable={false} />
       <TextField label="Privacidade" source="collectionable.privacy" sortable={false} />
       <ShowButton />
    </Datagrid>
  </ReferenceManyField>

...我的 collectionable_type 可以是另一个 Collection 或 LearningObject。

有什么方法可以为ShowButton 创建一个可自定义的 URL?

可能是这样的:

<ShowButton basePath={"/${collectionable_type}/${collectionable.id}"} />

【问题讨论】:

    标签: admin-on-rest


    【解决方案1】:

    &lt;ShowButton /&gt; 组件专用于创建指向由 admin-on-rest 管理的显示视图的链接。

    要在您的 Datagrid 中创建可自定义的 URL,您应该创建一个专用的 field component,如文档 Writing Your Own Field Component 中所述

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      • 2018-08-04
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      相关资源
      最近更新 更多