Using copy button to copy all loaded table objects

Hi!

I’ve been trying to get the new copy button to copy all the table objects displayed in a repeater list. The objects are loaded and set as a property in the Page Data model as follows:

GProp is then used to data bind with content logic for the copy button:

This returns the following result:

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

I can get the copy button to copy a single loaded object if I place it inside the repeater and bind it to the property displayed, but ss there a solution to get the copy button to copy all the loaded table objects?

Thanks in advance. Regards.

Hello @Erik_L
It’s hard to understand what’s going on here.
Can you provide us with your appId, pageName, and components names to see how everything works?

Regards

Sure! The appId is 7EDBBC57-D9EC-92BF-FF39-2D263F085100 and the pageName is ListTestCopy.

Pressing the component ButtonAside (in the sidebar) loads some objects from the Facts table and sets the objects as property GProp in Page Data. GProp is then set as repeater data in MinTTable (on the main page), with property Grund shown in component GrundTextarea.

With component CopyButton1 (in the sidebar), which is data bound with GProp, I try to copy GProp with the result [object Object],[object Object],[object Object] which are not the values stored in the table. The number of “[object Objects]” does however correspond to the number of objects retrieved from the table.

CopyButton2 (in the table on the main page) is data bound to property Grund in the table and pressing it does copy the correct value which is also displayed in GrundTextarea.

I didn’t notice your reply until now and I have been working on the app in the meantime so there are some minor changes made compared to the images I posted originally, but the problem remains.

Hello Erik!

Could you please create a new test page for us with just the logic that reproduces this issue and we will try to help you solve it.

Regards,
Alexander

Ok, so have a look at CopyButtonTestPage (same app id) instead.

When pressing the LoadObjectsButton objects are loaded from the data table TestTable. The loaded objects are set as property LoadedObjectsProp and the repeater below is filled with values. CopyButton1 is set to copy LoadedObjectsProp.

Each line in the repeater has a text area with data binding to the column ValueShownInTextArea. Each line also has a CopyButton2 which is set to copy ValueShownInTextArea.

CopyButton2 works but CopyButton1 doesn’t. CopyButton1 is instead returning [object Object],[object Object],[object Object],[object Object], the number of which is the same as the number of entries loaded from TestTable.

Hello @Erik_L!

Thank you for preparing a test page.

There is no error here and everything works correctly:
When you click on CopyButton1 you get this result, because LoadedObjectsProp contains an array of objects. To get those values you have to serialize it first.
For example like this:

And then the result of copying will look like this (I want to draw your attention, that in this case the repeater will not work):

Regards,
Alexander

That’s great - thank you! I hadn’t anticipated that so much more information would be copied. Even when only loading the property ValueShownInTextArea from TestTable I still get the result

[{"___class":"TestTable","ValueShownInTextArea":"Lorem ipsum dolor sit amet"},{"___class":"TestTable","ValueShownInTextArea":"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"},{"___class":"TestTable","ValueShownInTextArea":"Ut enim ad minim veniam"},{"___class":"TestTable","ValueShownInTextArea":"consectetur adipiscing elit"}].

Is there a way to only copy the actual values from the ValueShownInTextArea column, in the way that CopyButton2 does, but for all loaded objects?

Thanks for a great service and great support!

1 Like

Hello @Erik_L!

You can use the Map block to create a new array with only the values you want.
For example, ValueShownInTextArea:

In this case, the following value will be copied to the buffer:

["Lorem ipsum dolor sit amet","sed do eiusmod tempor incididunt ut labore et dolore magna aliqua","Ut enim ad minim veniam","consectetur adipiscing elit"]

And by this principle, you can bring your data to whatever you want it to look like.

Regards,
Alexander

Fantastic, that solves it for me, thank you so much!

//Erik