-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a target prop in ReferenceField #2022
Comments
React-admin requires that the records it manipulates have an Adding the |
No problem. I hadn't considered translating in the dataProvider. Thanks for the suggestion. Btw, you guys are awesome! I had this Datagrid with overly nested ReferenceManyFields and ReferenceFields. And it worked flawlessly. Really amazing what you are building! Again, 👏👏👏. |
Thanks a lot, we appreciate! |
@fzaninotto @aramando I was looking into adding this functionality myself and submitting a PR - I'm glad I checked here first! But with regard to the reason given here for not supporting a target prop on the I also don't understand why the requirement for all records to be primarily-keyed by an |
Sorry about coming in late to the party - one question for @fzaninotto: If you don't support joins on other properties (i.e.
|
No, there are no plans to remove it from ReferenceManyField. One of the reasons why ReferenceField requires that you use the id field is that we do an optim in datagrids having one ReferenceField per row to replace many getOne with one getMany... and this only works with the id field. We don't have (or plan to have) such optims in ReferenceManyField. |
@fzaninotto, I'm gitting the same constraints as many others, trying to add a ReferenceField to Datagrid in order to pull in data from another table on composite id or just any foreign key that's not id. I'd be most fine adding some translation logic in my dataprovider to do so, but lacking the ability to send any options to the dataprovider from the ReferenceField component. useGetManyAggregate does pass along meta to the dataprovider, but there's no way to send em through via ReferenceField component + useReference hook. I did an implementation in my codebase, but had to import 400 lines of code just to add 1 prop (=meta) to ReferenceField + the same prop to useReference. A big win would be the ability to set meta={...} props on ReferenceField that would be sent along to the dataprovider. |
If ReferenceField doesn't work in your case, use one of the the data provider hooks (like |
Is your feature request related to a problem? Please describe.
Consider
In some database all primary keys are named
id
instead of[table_name]_id
. I'm not saying havingid
as pk's is recommendable, but it is used quite often.Describe the solution you'd like
How about allowing a
target
inReferenceField
? Just likeReferenceManyField
is accepting bothsource
andtarget
.Describe alternatives you've considered
/
Additional context
/
The text was updated successfully, but these errors were encountered: