Skip to content
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

Autocomplete ReferenceInput #70

Closed
bjet007 opened this issue Oct 6, 2016 · 5 comments
Closed

Autocomplete ReferenceInput #70

bjet007 opened this issue Oct 6, 2016 · 5 comments
Assignees

Comments

@bjet007
Copy link
Contributor

bjet007 commented Oct 6, 2016

Is there any way to add more filter on a reference input field.

By Example, I have a list of products that belong to a category and I would like to list only product that match to one category.

I've seen that the method crudGetMatching use in the ReferenceInputField can accept a filter, but it doesn't seem to be exposed anywhere.

@fzaninotto
Copy link
Member

In the blog example, you can see how the Comments list offers a filter by post at https://github.com/marmelab/admin-on-rest/blob/7e4409ddf9a7c2d912d7aaaafee5b9b84b9068be/example/comments.js#L8-L10.

Is there a bug when you try to reproduce that?

By the way, <ReferenceInput> is now documented.

@bjet007
Copy link
Contributor Author

bjet007 commented Oct 11, 2016

I've seen that sample, but what I would like to achieve is to filter the item present in the reference input, not the filtering my list like in the sample.

If we take the post/comment example, what I would like to do is to filter the list of post when editing or creating the comment to only show post that match a predefined criteria. I'm not sure it would make sense in the example, but let's say we have thousand of post, I would like to only allow creating comment on post that have been published in the last week to limit my drop down to something manageable.

Right now, the only way that I could do it is by creating a new resources in my api that will do that, I don't think I can leverage the filter mechanism outside the list resource "pages"

Is that make more sense?

@fzaninotto
Copy link
Member

Gotcha, you want an autocomplete select box. Yes, it's very necessary, but it's not very straight forward since Material UI doesn't provide one out of the box.

@fzaninotto fzaninotto changed the title Filter ReferenceInput selection Autocomplete ReferenceInput Oct 11, 2016
@bjet007
Copy link
Contributor Author

bjet007 commented Oct 11, 2016

Kind of, In my specific use case, when editing my item, the dropdown is always a subset of the entire set of reference resource. I'm assuming that getting the Autocomplete Reference Input would allow me to "hardcode" my search queries without any user input.

@fzaninotto
Copy link
Member

Fixed by #199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants