Don't affect repeater's other rows

Hi there, let’s say I have a repeater with a circle inside of it like this:
image
And if I click the circle, the circle will be selected and become blue:
image
And if I click the circle again, it will become back to white.
However, if I click the button to add a new row to the repeater, the circle in the first row becomes back to white.
What I want is that adding a new row doesn’t affect the circle’s status in the old rows(if it’s blue, keep it blue; if’s white, keep it white). How can I do that? Thanks.

Hi!

The repeater redraws itself from scratch whenever an update is made. The Item Loaded event, which is called just before each row draws/redraws itself, is your opportunity to make changes to a given row before it is drawn to the screen. For example, If the Item Loaded event handler is empty, every row will look the same.

So what you’ll want to do is store the fact that the user clicked the blue circle in the repeater’s dataset:

  • Add a column called something like “dotSelected” that starts out with “false” (or just blank) in every row

  • On clicking a dot, update that row’s column entry to “true” if the dot is selected and “false” if it isn’t

  • Then, in the Item Loaded event, add the following after “enabling cases” for the event handler. (Below is pseudocode)

    On Item Loaded
      If true
        -- do stuff here that you want to happen on every row, 
        -- like setting the text of things to [[Item.columnName]]
      If value [[Item.dotSelected]] is equal to true
        show the blue dot
        -- Note that you do not need a condition to hide the blue dot,
        -- because if you do nothing, the dot won't show up
    

There is a useful article here that goes into excruciating detail on how to take advantage of the Item Loaded event handler, and also covers conditional logic (as you see above) and gives a primer on using expressions.

1 Like

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