Tallgeese
Tallgeese

Reputation: 75

Is it possible to override react-admin filter parameter?

I am new to react.js, and react-admin caught my eyes to use it. But I have a problem regarding to the endpoint it's using

http://localhost:3333/verifications/browse?filter=%7B%7D&range=%5B0%2C9%5D&sort=%5B%22id%22%2C%22ASC%22%5D

is it possible to remove the filter parameter? because I want to use my api which is

http://localhost:3333/verifications/browse?page=1&per_page=10&verification_level_id=1&verification_status_id=3

is it possible to override that? and use my api

Upvotes: 0

Views: 1673

Answers (2)

Raja
Raja

Reputation: 88

If you want to create filter like

?page=1&per_page=10&verification_level_id=1&verification_status_id=3
  • Here page=1&per_page=10 can be added by react admin list component, all you just need to pass props as pagination,per_page etc.
  • For the next part &verification_level_id=1&verification_status_id=3 you can create custom filter component and pass inside filter props and inside the filter component you can use useListContext hooks to get the filter.
  • List component will get this value inside filter as an object. Now you can access those filter on data provider and manipulate it and use it.
  • Please read https://marmelab.com/react-admin/List.html
  • https://marmelab.com/react-admin/DataProviders.html

Upvotes: 0

François Zaninotto
François Zaninotto

Reputation: 7335

Yes, it's totally possible: you have to tweak the dataProvider, which is a translation layer between react-admin's queries and your API.

Check out the documentation at: https://marmelab.com/react-admin/DataProviders.html

Upvotes: 2

Related Questions