我想在Create
,Edit
頁面內創建一個Datagrid
來顯示和管理n-to-n
關係。但我不知道如何將props
轉換爲List
和Datagrid
以及props
應該通過。Datagrid在創建,編輯頁面
管理這個Datagrid的資源名爲caregiver_student
,我把它放在我自定義的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>
謝謝您的幫助!
感謝您的回答,但有超過千名學生被百人班分隔。選擇一個學生 – M4yb3N3xtTim3
你的意思是你想在DataGrid中使用過濾器 – Gildas