Comparing current repeater item value to next repeater item value

Hi all,

I’m building a prototype for a contact list. One of the things I want is a header with the first character in the list. Example:

A
Allissa Evertson
Ally Canestro
B
Barnes Oxenford
Barry Tofallis

Where the first name is [[Item.FirstName]] and last name is [[Item.LastName]]

Right now I’ve manually added these headers in the repeater by only filling in the [[Item.FirstName]]. I then check, onload, if the LastName empty and change the state of the item to the styling of the header (get it?).

What I would like more is to have a list like this:

Allissa Evertson
Ally Canestro
Barnes Oxenford
Barry Tofallis

Where I compare the first letter of the current item (let’s say Ally) to the first letter of the next item (Barnes). If the first letter of these two values don’t match, I’d like to either: add a row inbetween with the first letter of ‘Ally’, or change ‘Ally’ into A (and change the state).

I’ve gotten as far as getting the first Character of Ally. I cannot retrieve the first letter of the first upcoming item to the one I’m comparing it to.

Hi oJoey,

Instead of retrieving the first letter of the next row and then comparing them to the current row (which may require the use of multiple conditional cases and global variables), have you tried sorting your repeater items alphabetically using the “Add Sort” action? Adding a sort to the repeater will automatically sort the items according to the specified property (e.g. “FirstName” or “LastName”) in ascending or descending order regardless of when the items were added:

Once a sort has been added to a repeater, any subsequently added items will also be sorted accordingly. You’ll be able to sort by numbers or dates as well, and added sorts can removed at any time by using the “Remove Sort” action. This tutorial might be useful if you’re not yet familiar with sorting repeaters:

Axure | Sorting Repeater Rows

Let me know if you have any questions about this or if you happen to be looking to do something else!

Hi Simon,

Thanks for your reply. I know about the sorting feature, but it’s not what I need. I have a contact list like so:

Right now my repeater data is like so:

So I have to manually put the ‘letter headers’ in the list. I guess I could start out with adding A-Z in my repeater, then sorting it so the headers would show up in the right position, but then I have to make sure to add a name for every alphabet letter to not have ‘empty’ sublists under a letter.

It would be nice if I could compare the current Item to the first following item to see if their first letter matches, if not add a header.

Hi oJoey,

Thanks for clarifying–I see what you mean. There is a way to target a specific piece of data in a repeater column, however this can only be done using the Mark/Update/Date Rows and Add Filter actions (you would also need to know the value of the entry you’re searching for). If you’re interested, Jane posted some examples of using those actions in this way here:

You might be able to use a combination of these actions depending on your current set up (possibly something like filtering for the following item that matches a condition, storing that item’s name into a global variable, and then comparing that with the current item), but there isn’t a way to directly access and retrieve a specific data entry of a repeater. I’ll go ahead and submit a feature request for a more direct way to do this and our PM team will be able to see what we can do, but using a sort might be the simplest way of getting this type of interaction in the meantime.