Display only certain rows in List view Mui
Hello everyone !! I have a user ressources in which i have all users (admin and non admin) and need to display only the admin user in the list view of the ressources. How can do that in my user list component or maybe in the DataProvider ?
7 Replies
Hey, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and could not find an answer. Please wait for someone from the refine core team or the community to try to help you. 👊
ambitious-aqua•2y ago
Hey @harisris, isn't filtering work for your case?
deep-jadeOP•2y ago
Hi @aliemirs in my case i don't want non admin user at all i only want to display admin. I don't know if it can be done with filtering
ambitious-aqua•2y ago
Depending on the data hook you're using, you can pass
filters
or if you're using datagrid/table hooks you can pass permanentFilter
to your query. If your data provider supports filtering, you'll get the filtered data (in your case only the admin users) and you can show the data thendeep-jadeOP•2y ago
I try and get back to you if I have issues
ambitious-aqua•2y ago
Good luck! 🚀
deep-jadeOP•2y ago
Finally i've made a function which update a roles state accord to a checkbox :
and i made my list like that :
i try to pass the data like that
rows={displayAdmin === false ? rows : adminsTab}
in the DataGrid but it does not work when the state is true
. How can pass dynamically to the DataGrid according to my state ? (dataGridProps rows
and my adminsTab
have the same format)
I finnaly found a solution :
the issue was that the admin was not store anywhere and was always empty