Reputation: 101
Im trying to show in a Datagrid
a Field
that is in a many to many relationship (intermediate table).
I have these tables:
group - group_subject - subject
group_subject also has attributes like rubrics and schedule
It's a many to many relationship. I would like to show in the <Resource>
group
all the subjects that a group is connected to.
Using something like the <SingleFieldList>
:
as this image
I'm using react-admin
. Is there a way to get values in this relationship?
Upvotes: 5
Views: 5958
Reputation: 1745
From react-admin
documentation <ReferenceField>
can be used for this purpose. More on documentation. Maybe this is a pretty late answer, but I think this can be helpful for others.
Upvotes: 0
Reputation: 7066
The easiest way would be to hide that intermediate table from react-admin. It's a good thing to hide this implementation detail anyway IMO. Users of your API shouldn't be aware of it.
from the groups
resource perspective, a group has many subjects, each subject having a group_id
and you API should allow to retrieve subjects by this group_id
field
from the subjects
resource perspective, a subject has many groups, each group having a subject_id
and you API should allow to retrieve groups by this subject_id
field
Upvotes: 1