Sort Repeater by Radio Button Selected Status

Hi, wondering if anyone has a suggestion for how to sort a repeater by the selected status of a radio button.
I have a repeater in which a pair of radio buttons are displayed. The user can select one or the other of the two radio buttons (they are grouped within the row, that is the repeater property, “Isolate Radio Groups” is checked). When the user clicks one or the other of the radio buttons, I would like the row containing that button to sort to the top of the repeater.
To put it another way, for each repeater row, the user could select that the row be “A,” “B” or unselected. As the user assigns rows to be A or B, I’d like the selected rows to be at the top of the repeater and the unselected rows to be at the bottom.
Right now, I don’t have a column in the dataset to store the selection state of the radio buttons. I suppose that would be one way to do it (and get around the possible problem of triggering OnItemLoad of the repeater?).
Any thoughts? Thanks in advance!

Hi Jaque!

Try the following:

Create a column (as you suspected) for the state of the button (let’s call the column “radioState”).
Make sure the radio buttons are in a radio-group, so that selecting on deselects the other.

On the A button:

   Update Rows set radioState to "A" for This in (repeater)

On the B button:

   Update Rows set radioState to "B" for This in (repeater)

Add this to OnItemLoad in addition to anything that’s already there (note: be careful about IF vs Else IF. You can right-click to toggle between them):

If (value) [[Item.radioState]] is equal to A
   select radio button A
Else if (value) [[Item.radioState]] is equal to B
   select radio button B

In OnLoad of the repeater (NOT OnItemLoad):

Add Sort radioState as Text ascending

Note that when you update a row (via selecting a radio button), the repeater will re-evaluate the sort automatically.

The experience may feel funny, as the row you select will immediately jump out from under your mouse. You might want to put a Wait command upon selecting a radio button to create a delay before updating the row.

Here’s an example (I added a wait of a quarter second): sorting_radio_buttons.rp (55.5 KB)

1 Like

Will give it a go … looks spot on, so I’m pretty confident of success.
Props to you for some of the clearest indications of how to build something. I have to say that many responses here in the forum are not nearly so well-documented. Thanks for taking the time!!

1 Like