How to add new rows of data into a repeater using a button

Hi all, I’m creating a prototype for a gaming app and I’m trying to make a way for the user to click on numerous buttons, each with a different value, and store them in a table in the order they were clicked in. I’ve tried using repeaters and got close, but every time I click on a different button it will overwrite the pervious value. Any guidance will be appreciated.

Thank you.

It will probably be most efficient if you can post your .rp file here. That will allow folks to see just how you have things arranged and offer solutions which you can then inspect and learn from.

In general, when you dynamically change data in a repeater you want to do it by updating the repeater sheet (the “dataset”) and not directly on the repeater widgets–such as the text value of a label. It is important to know that any time you change the repeater, whether it is adding or deleting a row, sorting, filtering, etc. the entire repeater gets reloaded, thus firing the OnItemLoad event and thus setting widget values based on what is in the repeater sheet, not what is currently on the widgets themselves.

Exactly how you should do this will vary depending if your button is in the repeater itself or outside the repeater. in general, if the button is in the repeater and you want to change a widget’s value in that same row, you would call an Update Row action, pointing to “This Row”, change the value for a specific column in the repeater dataset, and handle the change in the OnItemLoad event. And, in general, if the button is outside the repeater, you first need some way to identify which row(s) need to be updated. This is done by specifying a rule in the Update Row action, such as [[Item.index == '3']] or [[Item.Name == 'Adam']] or [[Item.Gender != 'Male']].

If you’re still using RP8, like me, learning repeaters just got a lot harder… RP9 is now officially released and Axure has updated all their support and reference material for RP9 only, and it looks like a lot of their tutorials have been lost or not yet created for RP9. Repeaters have not changed that much, though… Here is the reference page and section which might help you:

EDIT: I recently learned that all the RP8 reference material is still available here:

1 Like

I’ve got a related issue in something I’m creating (in Axure 8). I’m keeping track of single item which has a list of other things to which it is related. For instance

  • “Cat” is related to “purrs” “sleeps” “plays”
  • “Dog” is related to “barks” “plays” “fetches”

In my prototype, I want the user to be able to edit the lists of related things, for instance add “nap” to “Cat.”
IRL, I’d have a relational database or at the very least use an array. But I haven’t found such structures in Axure. So I am faking an array by using a string of the related items separated by the pipe character (" | “) (but you could use any character that you are sure is not going to appear in your data). Then I make use of javascript string manipulation functions such as .concat(), .substr() and .replace() to add, change and delete items. Something like that might work for you, i.e. each time the user clicked a button, add the ID of that button to your variable.
ButtonClickOrder = “”
user clicks a button
ButtonClickOrder = ButtonClickOrder.concat(”|".concat(value-of-clicked-button))
(repeat previous two steps . . .)
at any point the string in ButtonClickOrder will look something like
and you can evaluate it to try to do something with it. This could be in a global variable, or in a cell within a repeater.

Looks complicated. Because it is complicated. It might be helpful.

In my implementation, doing something like this for many rows within a repeater, it works, is hard to maintain and runs very slowly. I keep reminding myself “it’s just a prototype.” And fortunately for me, this is not for testing with unknowing users, it’s more just to demonstrate the idea and stimulate discussion, so it doesn’t have to work quickly and for all use cases.

From what I’ve seen on the forums, the advice offered by @mbc66 is consistently good, so definitely see if his advice can help you.

1 Like

Hi mbc66, thanks for the reply, here is the axure file Repeater Issue.rp (54.7 KB)
I see from your reply that I have been going at it the wrong way, I will try it again and get back to you. Thank you for the help.

@wjh @mbc66 I’ve managed to get it working, thank you guys for the help, it’s much appreciated. I will upload a file of it working for anyone who wishes to see it. Repeater Solved.rp (57.9 KB)

@Toche Haha, oh my, the advice I gave was way way off in left field compared to what you were asking! Thanks for posting your solution, I learned something from examining it. Also, I believe in the OnClick event for each button, you don’t need to set value of Xvar equal to [[Xvar]]. I removed those lines from the four buttons and the example still worked.

1 Like

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