Copying only selected rows and certain columns

Hello again!

We are working with google spreadsheet, and sharing it with an external organization. this spreadsheet is constantly being updated; the source of information is a retool table.

I would like to be able to copy a bunch of selected rows from that table, and only certain columns of these rows.

I have tried using table1.selectedRows, but it didn't work.
I also tried "{{ Papa.unparse(table1.data, { delimiter: '\t' }) }}" but it copies the entire table, and that is not what I need, unfortunately.

any help would be appreciated!

thank you.

Hey @ronasilb
The way you could do this is using selectedSourceRows, and then using filter and map function to pinpoint to what you want to to copy and how to format the data so it fits your use case.
So if you set the table row selection to multiple and set an event handler to Select row and Copy to clipboard. Then for the value you would write your logic

{{table3.selectedSourceRows.filter(x => x.name && x.id).map(x => x.name + " " + x.id).join(", ")}}

Or if you want multiple ones here is the example

{{table3.selectedSourceRows.filter(x => x.name && x.id).map(x => x.name + " " + x.id).join(", ")}}

Hope this helps! :sun_with_face:

Thank you for your answer!

I was able to re-create the first example, but not the second. So I wasn't able to copy more than one column.

however - I will add a few things I forgot to mention:

  1. I am using a button to copy - I do not want to copy rows upon selection (but that's easy)
  2. I will need to copy them in a form of a table. so - without the "," - but with tabs, and line breaks.

any help would be much appreciated!!

thank you :slight_smile:

Hi there! I think Milan's solution is really great! You may just need to write a function to loop over the selected array and format it how you'd prefer with tabs and line breaks.

1 Like

Thank you Abbey and Milan!
I was able to solve this a bit differently with the help of @Louis_Rappaport:

{{
table1.selectedRows.map(obj =>
${[obj.id](http://obj.id/)}\t${obj.column1name}\t${obj.column2name}\t${obj.column3name}
).join('\n')
}}

this worked perfectly for me.

thank you everyone!

2 Likes