How to perform a count of related entities in a grid? #3001
-
in a i've tryied to use should i've to use another hook like the structure of posts collection of https://api.fake-rest.refine.dev/posts has this shape:
what i've tried, that is obviously wrong export const CategoriesList: React.FC = () => {
const { dataGridProps } = useDataGrid<ICategory>();
const categoryIds = dataGridProps.rows.map((item) => item.id);
const { data: postsData, isLoading } = useMany<IPost>({
resource: "posts",
ids: categoryIds,
queryOptions: {
enabled: categoryIds .length > 0,
},
}); could you suggest me some something? is there any example how to perform a count? this is my repo with a draft: https://github.com/pinale/Refine/blob/master/refinemuiapp/src/pages/categories/list.tsx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @pinale, I've created a StackBlitz fork for answer your question. Here is the link. With this method, you send requests for each row render, but don't worry, the react query cache saves you. |
Beta Was this translation helpful? Give feedback.
Hey @pinale,
I've created a StackBlitz fork for answer your question. Here is the link.
With this method, you send requests for each row render, but don't worry, the react query cache saves you.