I have a query and I want to include a button that when clicked will copy the data in that query to the user’s clipboard. How do I go about doing that? Thanks!
Hey @joew! The Button component in Retool lets you choose “Copy to clipboard” as one of the actions from the “On click” dropdown. In the “Value to copy” field, you can reference {{ query.data }}
.
hi @justin hi can I copy a json do clipboard?
If that is an array you may need to add a dot after data and see if [0] comes up and add that if it’s a singular object
{{getSelectedRemittanceOpenDetails.data[0]}}
Or try
{{getSelectedRemittanceOpenDetails.data[0].toString()
Or try
{{getSelectedRemittanceOpenDetails,data.toString()
Hey @igoraguiar! Echoing @ScottR's comment, are you interested in copying a single value or the entire data object? If the latter, this "Copy to clipboard" action expects the value to be a string.
You could copy the stringified version of your data if that helps at all!
{{ JSON.stringify(query.data) }}
Thanks guys. It worked perfectly with the JSON.stringify
Very glad to hear it
A problem I ran into was being able to copy to google sheets. The following makes the data easier to copy and paste into your google sheets or excel:
{{ Papa.unparse(formatDataAsArray(GetActors.data ), { delimiter: '\t' }) }}