Skip to content

A link with parameters to filter a related list page #3007

Answered by alicanerdurmaz
pinale asked this question in Q&A
Discussion options

You must be logged in to vote

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>

You can refer to qs for more information about syntax.


First create <Link/> like this.

// 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 syncWithLocation:true prop to use…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by omeraplak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants