two list pages with same resource
I need multiple list pages which are using same resource but with a different permanent filters. so those pages will display different data.
but two list with same resource is not showing in the sidebar. any way to fix
8 Replies
Hi @alfaz_muhammed. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, you can create multiple list pages using the same resource but with different permanent filters. This way, each page will display different data based on the filter applied.
For example, you can use the
useSimpleList
hook in refine to apply a permanent filter to your list. Here's an example of how you can do this:
In the above example, the list of products is filtered based on the storeId
obtained from the Store Context. This way, you can control more than single content in one application.
As for the issue of the same resource not showing up in the sidebar, it's important to note that by default, refine generates the sidebar based on the resources defined in the Refine
component. If you want to customize the sidebar, you can use the Sidebar
component and define your own routes.
Unfortunately, the extracts provided do not contain specific information on how to customize the sidebar in refine. For more detailed instructions, you can refer to the refine documentation (https://refine.dev/docs).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@763439201353596968> kapa.ai is still learning and improving, please let us how it did by reacting below
conscious-sapphire•15mo ago
@kapa.ai in my sidebar i'm using useMenu to get sidebar menu items.
Let me check the knowledge base for you. One moment! :books:
----------------------
The
useMenu
hook in refine is used to generate menu items based on the resources defined in the Refine
component. It returns an object containing menuItems
, selectedKey
, and defaultOpenKeys
.
Here's an example of how you can use useMenu
in your sidebar:
The menuItems
is an array of objects, each representing a menu item. Each object has a name
, key
, route
, and children
properties. The children
property is an array of objects, each representing a submenu item.
If you want to create a multi-level menu, you can use the children
property to define submenu items. Here's an example of what the menuItems
might look like:
In this example, "CMS" is a menu item with two submenu items: "posts" and "category".
For more information on how to use useMenu
, you can refer to the refine documentation (https://refine.dev/docs/api-reference/core/hooks/ui/useMenu/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@763439201353596968> kapa.ai is still learning and improving, please let us how it did by reacting below
conscious-sapphire•15mo ago
in my resource, I have defined two items with same name, and when i use useMenu, only one is there which is first defined one
@kapa.ai in my resource, I have defined two items with same name, and when i use useMenu, only one is there which is first defined one
Let me check the knowledge base for you. One moment! :books:
----------------------
The
useMenu
hook in refine generates menu items based on the resources defined in the Refine
component. If you have two resources with the same name, useMenu
will only generate a menu item for the first one.
To create separate menu items for each resource, you can use the meta.parent
property to nest resources under different parent labels. Here's an example:
In this example, "posts" and "categories" are both nested under the "CMS" parent label. This will create separate menu items for "posts" and "categories" in the sidebar.
For more information on how to use useMenu
, you can refer to the refine documentation (https://refine.dev/docs/api-reference/core/hooks/ui/useMenu/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@763439201353596968> kapa.ai is still learning and improving, please let us how it did by reacting below