A link with parameters to filter a related list page #3007
-
according to https://api.fake-rest.refine.dev json I've a on the CategoryList page i have a link to related posts, what i expect is to be redirected to the PostList page with filters setted according to the link parameters for the cetegory link i've used (but it isn't correct)
so, it should be somethig like:
this is the example: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @pinale, i created example repo based on @salihozdemir previous answer. You can use
First create // src/pages/categories/list.tsx
<Link to={`/posts?filters[0][field]=category.id&filters[0][operator]=eq&filters[0][value]=${row.id}`}>
{filteredPosts?.length}
</Link> After you should give // src/pages/posts/list.tsx
const { dataGridProps } = useDataGrid<IPost>({
syncWithLocation: true,
})
|
Beta Was this translation helpful? Give feedback.
Hi @pinale, i created example repo based on @salihozdemir previous answer.
You can use
syncWithLocation
feature of<Refine>
.When you enable the
syncWithLocation
the filters can be infered the URL so when you change the URL params the filters apply automatically. The filter syntax like below:?filters[0][field]=category.id&filters[0][operator]=eq&filters[0][value]=<some-value>
First create
<Link/> like this.
After you should give
syncWithLocation:true
prop to use…