Save repeater contents to global variables, then use them to build a copy of the repeater?


#1

Hi gang,

I’ve got a repeater being used as a shopping cart. For the purposes of my prototype it has a maximum of 3 items (rows), but can have as few as 0 when the cart is empty. There are columns for Name, Price, and Quantity.

What I need to do is re-create the cart repeater in a couple of different places… Because you cannot directly clone a repeater (feature request!) I feel the easiest way to do this may be to store all the info in global variables, then rebuild the cart using those… either as a new repeater or as a non-editable mock copy of it.

So my question is: how would you go about pulling the data out of a repeater and into some variables?
OR do you have some better way to solve this problem?

Thanks for your help!


#2

Since it sounds like you’re going from one page to another and that it’s not possible to pass parameters from one page to another using the URL, I think you might be able to append the data into CSV format then hash it out onLoad of the new page.

For example, column “FirstName” would dump into global Variable “FirstName” and would look something like “John, Carol, Wolfgang”

Then you would build a compound String operator that searches for the first occurrence of a coma in the string, then adds a new row to the new repeater where FirstName2 = [[FirstName.substr(0, FirstName.indexOf(’,’))]]. Then just slice out that name from the global variable then do it again.


#3

Also looking for a solution to save a repeater globally.
@jlhelmers that’s an awesome idea, thank you! Do you have a .rp file wich shows that? I have issues with the code.
Thank you in advance!


#4

If you’re looking for an example of how repeater data can be stored in global variables and used to re-create the repeater on another page (or have the data persists when you leave the page and return) then the post below and its example should be helpful!


closed #5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.