I've read on other topics (now closed) that it should be easy to copy/move components between pages by copy/cut and paste.
I've been trying to move come components and run into several kinds of trouble.
Taking the first issue first....
If I were to Copy & Paste it's pretty obvious that the new pasted component needs a new name (ie a new suffix number), but i would expect that if I use Cut & Paste then the component's name should be preserved.
But this doesn't happen. I Cut "multiSelect3" and when i paste it back on another page I get "multiSelect28". I have only 8 components to move, but if they all get new names then it means that none of the queries will work.
I know I can rename the components and so with a bit of effort put them all back to the original names - but that just leads to the second problem.
But first - why can't Cut & Paste preserve the component's name?
1 Like
Hey there David,
Yeah, this is annoying and I agree with you that cut and paste should persist with names.
However, I think there may be some sort of logic behind this
- For every new component added into the canvas, the platform checks:
-- if there are any other components with the same name
-- If there are, it will add the next sequential integer number to the name
- In fact, if you add a select component and rename it to select11, and then another one it will name it select12.
- The same thing happens whenever you paste components, whether that's from copy of from cut
- In fact, if you cut+paste the component with the highest integer after the name, the name will persist. But that won't be the case if there is another component with the same name + a higher integer name next to it (it will assign the highest number to the component you just pasted)
So having understand that, you at least will know whether Retool will rename or not the components.
A solution for this is renaming your components to something unique, and with that you will ensure that whenever you cut and paste them the name will persist.
1 Like
Hi Miguel,
Yes, i tried that, and the good thing is that references to the component, eg in queries, are automatically updated.
UPDATE: later I found that the references within GUI database updates don't get adjusted automatically - they have to be done manually
The trouble is, that the section I want to move has (at a quick count) about 23 components,
Finally I managed to move the page contents with "bearable" amount of effort.
- Make sure to have a saved copy of the App. I got in a mess at least 6 times, had to delete the App and start again from a fresh copy of the last version.
- It's best to create a new folder for the queries, drag/drop them into the folder, and then use "Right-click/Move to page" to move the whole folder to the new page.
- Renaming all the components before moving them was easiest by just adding a letter "A" (or any other of course) to the end of each name. That stopped the auto incrementing on cut/paste.
- Although it's possible to select multiple components with Shift-click, it seemed safer to take them (cut/paste) one at a time to the new location.
- I was worried in the case of a table which has expandable rows, with a tabbed container in the expansions and a table and other components in the tabbed sections. Almost all came through on one cut/paste of the outer table. But mysteriously two embedded components disappeared and I had to recreate them.
- As noted above, the GUI queries have to be updated with the changed component names.
1 Like