Updating all Repeater Rows but only 1 Column

advanced-prototyping

#1

Hey Folks,

I have a problem which i can´t solve myself… I have a repeater for Products which can be replaced by others which are more expensive or less. It should be added or removed from a total value.

I just cant get how to update the rows properly to exchange the values. The next Problem is how to change to “+” to “-” to get the positive or negative number.

Maybe there is a simple solution for this but right now I´m stuck for hours on this problem.

Here is my example file: upselling_repeater.rp (52.6 KB)

Maybe some of you ran in the same problem like me.

Thanks for your time :slight_smile:


#2

It is not clear why or how you are trying to update the repeater… I don’t see anything in your file that does anything to update the repeater rows, nor why you’d need to do so. Could you explain more about what you are trying to achieve?

From your post title, you want to update a column value for all rows in a repeater, yes? When using the Update Rows action you can edit the values for any and all columns. You can target all rows by defining a rule for an Update Rows action that applies to all rows, like [[Item.Num > 0]] or [[Item.Name != '']]. Or, as I prefer for reliability, you can mark all rows then update marked rows, then if needed unmark all rows, like this:

Mark Rows
my_repeater all rows
Update Rows
my_repeater set Name to “New Name String”
Unmark Rows
my_repeater all rows

Here is the reference documentation for repeaters in RP9:
https://archive.axure.com/axure-rp/reference/repeaters/

What does it mean to replace a product with others? How and why would this happen? Should the selected row be updated somehow, or maybe removed/hidden when chosen? The row group gets selected when you click it, so that’s a status you can query if needed–although it is not a true repeater datasheet update.

Is this part of the “product replacement” or different? Also, what defines adding versus removing? Do you mean that it just increments by a positive number and decrements by a negative number–like a discount?

In your example, you have a starting price of 100 Euros shown in a widget named, “total_price”, and it looks like you are intending to update that total based on the choice of one of the three items in the repeater list. …Or maybe you intend to exchange the price of the selected item with the value of the “total_price” widget? Basically, what should happen if you click the third Product item in the list, with a value of 400? Should “total_price” then be 500, or should it be 400? Should anything else happen to the selected row–or any other row in the repeater–like maybe the selected row becomes “Product 0” with a price value of 100, which would be an “exchange”? Then, if you click the first item, with a value of 0 Euros, should “total_price” then be 100 again, or 0, …or 500?

If you need to update the Price total, then you’ll want to use a Selected event rather than the Click or Tap event, otherwise the total keeps on rising every time you click on a row–even if it has already been selected/clicked. Additionally, I don’t see why you’d need to store the value of the selected row in a global variable, because you never do anything with it. However, if you need a starting default price (100 Euro) then you’d want to store that so you can restore it, and use it in your calculations.

It’s a little odd you have this as a separate widget, and more odd that you have the cents as a separate widget. There are ways to format one string value with all of this, but for now, keeping your structure here, you can easily do this by testing if the value in your datasheet cell is less than zero, meaning it is a negative number. You’ve got a widget in your row group with a text value of “+” so you’d just need to set the text value to “-”. You can do this with a conditional case in your repeater’s Item Loaded event (see below.)

Then, because you have this separate sign widget ("++price_tag") you would not want to show the minus sign in the price widget’s value (named “++room_price”) --assuming you would code the data in the repeater datasheet as normal for a negative number, like “-50”. So, in your action to set this text, you’d need to use the absolute value, which would result in “50”. You can use the built-in Math.abs() function like so:

Set Text
++room_price to “[[Math.abs(Item.CPrice)]]”

I updated your file with a “Page 2” to show how you can get this to work, based on my guess of how you want this to work–but again, I’m not too sure I understand just what you intend. My assumptions here are:

  • There is a default starting price of 100 Euros.
  • The user can select one and only one item from the repeater list.
  • A selected list item’s price value gets added to the default starting price, showing the resulting total.
  • Additionally, if the user clicks a selected item (again) it can deselect it, also updating the total.

Here is what I changed:

  • In order to keep track of the starting price, I added a Loaded event to the “total_price” widget that sets the global variable, “Price”. So, you can edit the starting price directly on the canvas, and when the prototype page loads, it will automatically set the global variable.
  • In the repeater’s row group, the Click or Tap event has a Set Selected/Checked This to “toggle” (instead of “true”; so user can choose it but also cancel that choice so none are selected.)
  • I removed the Set Variable Value action as it is not needed here.
  • I moved the “Set Text total_price” action to the Selected event of the radio button widget (which I named “radio”). Axure does not have a Selected event for Groups (which is odd, because a group can be selected and unselected) so an individual widget within the group must be used instead.
    • So, clicking on the group selects/unselects this group, which automatically selects/unselects all widgets in that group.
    • When “radio” is selected, it sets the value of “total_price” to “[[Price + item.CPrice]]” , so this row’s price value is added to the starting price.
    • When "radio is unselected, it sets the value of “total_price” to “[[Price]]” …just the starting price, becuase nothing has been added to it.
    • If you don’t want the user to be able to click an item to unselect it (as in a true radio button behavior) you can delete the Unselected event. …Perhaps the intent of “Product 1” with 0 Euro value is intended to be a “None” selection?
  • I also added a “Product 4” with negative value (CPrice cell is “-50”) to demonstrate how this works.
    • In the repeater’s Item Loaded event I added a conditional case to change the “+” widget to “-”

If [[Item.CPrice]] is less than 0
Set Text
++price_tag to “-”

upselling_repeater.rp (70.9 KB)


#3

Hey mcb66,

Thank you for your time and help. I got it figured out and saw that i didn´t descibed my aims clearly.

So at first lets take an example like a travel where you book rooms and can upgrade them. In this example the travel costs are 2312,00€ and you have a basic room called “Room 1”. You can get a better room called Room 2 or 3 and pay some more money. So the price needs to be + xxx € and if i choose them the price should be added to the total pirce. All other items in the repeater should be recalculated on base of this new pirce and should show how much less or more the other rooms would cost.

I figured out how to do it meanwhile i wanted to show you my solution (maybe i could make sth better). I also added that the first option is always selected so its clear this is the base “room”.

I solved the + - sign problem a little different - i used the “Text Changed” event and manipulated the pricetag this way. But the [[Math.abs(Item.CPrice)]] would be more elegant i guess.

I edited the 2nd page and hope you find it usefull :slight_smile:

What I used to update other items on selection is the TargetItem of the repeater. So i can manipulate every marked row how you already said.

Thanks for your help and feedback!

Kind Reguards

upselling_repeater (1).rp (74.3 KB)