我想在Datagrid
,Create
页面中创建Edit
以显示和管理n-to-n
关系。但我不知道如何将props
传递给List
和Datagrid
以及props
应该传递的内容。
用于管理名为caregiver_student
的此Datagrid的资源,并将其放入我的自定义restClient
文件中。
这是我的代码:
<Edit title={<CaregiverTitle />} {...props}>
<TabbedForm>
<FormTab label="Personal Info">
<DisabledInput source="id" />
<TextInput source="name" />
<TextInput source="email" />
<TextInput source="phone" />
<RadioButtonGroupInput source="account_type" choices={[
{ id: 10, name: 'Caregiver' },
{ id: 20, name: 'Guardian' },
]} optionText="name" optionValue="id" />
<BooleanInput source="status" label="Active"/>
</FormTab>
<FormTab label="Relationship">
<List actions={<RelationActions/>} location={false} title={" "}>
<Datagrid>
<TextField source="id" />
<TextField source="name" label="Student"/>
<TextField source="relationship" />
<EditButton />
<DeleteButton />
</Datagrid>
</List>
</FormTab>
</TabbedForm>
</Edit>
感谢您的帮助!
答案 0 :(得分:0)
链接的资源应包含在ReferenceManyField
中您可以在演示中找到完整的示例, 特别是Customers Edit component
有人开了一个可能有帮助的公关:https://github.com/marmelab/admin-on-rest/pull/744
答案 1 :(得分:0)
我有一个类似的页面,其中的标签列出了&#34; Batchunits&#34;属于特定&#34; batchid&#34;。
<FormTab label="resources.batches.tabs.batchunits">
<ReferenceManyField addLabel={false} reference="Batchunits" target="batchid">
<Datagrid bodyOptions={{ stripedRows: true, showRowHover: true}} >
<TextField source="unitcode" />
<DateField source="harvested" />
<BooleanField source="contaminated" label="Contaminated"/>
<TextField source="note" style={{ maxWidth: '10em', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }} />
<EditUnitButton />
</Datagrid>
</ReferenceManyField>
</FormTab>
但是在此设置中,Formtab将不接受创建&#34;按钮&#34;创建另一个资源的记录。例如另一个&#34; Batchunit。创建另一个链接的Batchunit非常有用。不知道该怎么做......