-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get current object path with custom button #35
Comments
@olavim Now it returns 4 parameters: value, keyName, keys, parentValue. Could you give it a try? <Copied
as="span"
render={({ 'data-copied': copied, style, onClick, ...props }, { value, keyName, keys, parentValue }) => {
const styl = { whiteSpace: 'nowrap' }
if (copied) {
return <span style={{ ...style, ...styl }}>复制成功</span>
}
return <span style={{ ...style, ...styl }} onClick={onClick}>复制</span>
}}
/> |
@olavim upgrade |
Thanks for the quick response! The change is working well for me. |
This does not return the json path as the author intended. I am on ^2.0.0-alpha.23 and parentValue returns { |
@nnurmano the |
Indeed! Sorry, I was looking at the wrong place. |
Hi, I also have a similar use case, thank you a lot for handling it! It would be even better to have something like Current solution is coupled with the copy feature and will not work with Example:
|
@lsst25 You can achieve it using <JsonView.Copied
render={({ 'data-copied': copied, style, onClick, ...props }, { value }) => {
const styl = { whiteSpace: 'nowrap' }
return (
<div>
<button onClick={() => hanleCustomAction(keys)}>Custom Button</button>} />
<span style={{ ...style, ...styl }} onClick={onClick}>
{copied ? "复制成功" : "复制"}
</span>
</div>
)
}}
/> |
I'm trying to add a button next to the copy button which would get me the current object path. For example, if I have the object
and I clicked the button on the
"foo": "bar"
row, I want to return"data.foo"
. Similarly, if I clicked the button on the"data": {
row, I want to return"data"
.Here's an image with the button for reference (fake data)
My first attempt was using the
JsonView.Copied
component renderer to just throw the button next to the copy button, but I don't have access to the current path in the object there. The renderer only knows the key and value of the row. I don't see how I would achieve what I want with the other available component renderers either.Is there a method with the current functionality? If not, would it be possible to add support for this use-case?
The text was updated successfully, but these errors were encountered: