Passing values to a create button
I want to have a specific create button in the table view. So when I press the create it should also passes the ID of that row in the table where the button is present.
When I'm at the create view then I can retrieve this ID of the row. How can I do this?
3 Replies
Hi @Busulle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To pass values to a create button and retrieve them in the create view, you can use the
meta
property of the CreateButton
to pass additional parameters. Here’s how you can achieve this:
1. Using CreateButton
with meta
property:
You can pass the row ID as part of the meta
property when you define the CreateButton
. This meta
property can then be accessed in the create view.
2. Accessing the meta
property in the create view:
In the create view, you can use the useParsed
hook to retrieve the passed meta
data.
Here is an example of how you can implement this:
Step 1: Define the CreateButton
with meta
property
Step 2: Retrieve the meta
property in the create view
In your create view, you can use the useParsed
hook to access the meta
data passed from the CreateButton
.
Additional Information
- Documentation on CreateButton
: CreateButton Documentation (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/create-button/)
- Documentation on useParsed
: useParsed Documentation (https://refine.dev/docs/core/hooks/utilities/buttons/#usecreatebutton)
By following these steps, you can pass the row ID from the table view to the create view using the CreateButton
and meta
property. This allows you to pre-fill or use the row ID in your create form.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@281353575504805888> kapa.ai is still learning and improving, please let us know how it did by reacting below
passive-yellowOP•8mo ago
That does not work:(