#Retrieve Current WhereFilter in ListMenuItem
20 messages · Page 1 of 1 (latest)
Original message from @minor carbon - Moved from #general message
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Hey @minor carbon
Is this in the Edit view or List view?
I think there are helpers for this
@vague ice In List View. All the code I find is using DocumentDrawers, but I can't out how for example the query preset gets the Wherefilter when you create new.
Yes, that's it. Thank you!
Glad your issue was resolved! :tada: If you want to help make payload better, please give us a :star: on GitHub and review us - It helps us a lot.
My pleasure my treasure
@vague ice If I now want to manipulate the query and fetch the data. Should I initialize a new payload instance with getPayload or use the usePayloadAPI hook or is there another way to retrieve the payload instance?
Is this in a client component? Because you cannot get the payload instance in there, have to use either a server action, typical fetch for REST api, or custom endpoint
In server components you can use the req passed into your component
In a server component I would not be able to use useListQuery I suppose.
Thanks again.
No, but you could wrap a client component in a server component for the best of both worlds
@vague ice Server actions work for me for now. But I wonder how it would be with your example. Do you mean
<ServerComponent>
<ClientComponent />
</ServerComponent>
```?
My ClientComponent is a Button, but in this way it is not displayed. So I probably have to wrap the button with another client component? How do I pass the query from `useListQuery` back to the server component to perform the task? In my case: create an excel file for download ? Afaik data can be passed from server component to client component, but not back again.