Repeater Content across pages


#1

Just looking for an explanation since I’m missing something.

I have a repeater on a page, being feed by a text input. Type in the field, enter, and a row is added to the repeater; pretty basic and having no issues. My problem starts when I need that repeater content on the next page. I’ve looked at the Axure tutorials and tried to follow several instructional guides but am still missing something.

Is there a simple way to pass repeater information to another repeater on another page?


Pass data from input page to the repeater of another page
Saved / favorited items: Can I make updated repeater rows permanent?
#2

In a word, no.

The only way to pass data of any kind from one page to another in Axure is to use global variables. So, if your repeater is simple/short enough, you could convert everything in your repeater dataset on the first page to global variable(s) and then on the second page use the OnPageLoad event to read the variable(s) and update a similar repeater on the second page. If your repeater data is more complex, then you could create a “hash scheme” to pass only enough data to recreate or update what you need. For example, instead of passing “Lorem ipsum dolar sit amend” you could pass a hash of “L” with a condition on the second page to convert “L” into the longer string, or show an image, or unhide a repeater row where that data is preset, etc.

Another approach would be to fake the page change, so instead of opening a link to another page in your prototype, just stay on the same page and change a dynamic panel state so that it looks like a new page has been loaded. then all your repeater data is still available.

Here is a recent thread with same basic issue and some proposed solutions:


#3

List is very short, single column maybe three items.


#4

OK, then this can be relatively straightforward. I’ll assume the list can vary in length and contains just a single word (but same approach would work with multiple words or numbers per row.) We can concatenate your repeater rows to a global variable, like OnLoadVariable, separating rows with a char that could not appear in the content, say like a comma. So a repeater like this…

Ant
Bird
Cat
Dog

…would result in a string of “,Ant,Bird,Cat,Dog” which is a valid value for OnLoadVariable. Every time a new row is added to the repeater, it would append its text value to OnLoadVariable. Then, on the second page, the OnPageLoad event could create a repeater by parsing the variable at the commas. Make sense?

Here is an example:
Pass Repeater with Variable Parsing.rp (84.4 KB)

A text field allows entering text. If spacebar or Enter pressed it triggers the “ADD TO LIST” submit button, which adds a row to the repeater with the value of the text field. Here is the code for the repeater:

image

and because the key part got clipped, here’s the last line:

image

Because I decided to have the repeater handle the OnLoadVariable string itself, it is critical to reset OnLoadVariable (to blank) for the first row. This method of handling the string in the repeater means that rows can be deleted and the OnLoadVariable string is properly updated. The order of entry is preserved as well.

When Page 1 loads, the OnPageLoad event first ensures that OnLoadVariable ends in a comma char (which simplifies the logic for creating repeater rows and properly ending when the list of row elements is done) and then calls a “list creator function” to iteratively parse the OnLoadVariable string. This “function” is a dynamic panel set to “Next wrap”. Each time it changes state, it adds a row to the repeater and removes the first word, then changes its state again until there are no more words in the list. This kind of recursive function works well for an iterative process like parsing a list of words.

To get the first element in the list, we can use this formula:
[[OnLoadVariable.slice(1,OnLoadVariable.indexOf(',',1))]]
The slice() function extracts a string from OnLoadVariable, but does not alter OnLoadVariable. So, after adding a Row with this formula, I strip it out using this formula:
[[OnLoadVariable.substring(OnLoadVariable.indexOf(',', 1))]]

So, that’s basically it. Hope this approach works for you.


How to pass/update repeater data in different pages
How do I extract all of the values returned using the Split method?
External Javascript not working properly on macOS - timing?
Repeater - add to cart - calculate the final price
Repeater List - Soo far soo good. then Boom :)
Persistant rows in repeater when adding values from another page
Seeking Guidance on Unusual Behaviors in Azure RP: Circle Appearance and Item Movement Issues
#5

So useful @mbc66. Thank you!

I would like to add a detail. You make use of indexOf like this: OnLoadVariable.indexOf(’,’,1).

The second parameter is not documented in Axure.
However it works fine. It means ‘start searching from n’ where n is an index value.

Hope this helps.


#6

Yeah, good point. Very little of the string and math functions are documented, but they are actually javascript functions, so you can easily find documentation and examples on the web. Stack Overflow is a great resource.