Assign numbers (ID's) to rows in repeater

newbie-question
repeater-widget

#1

Hi all!
Hope everyone is staying healthy and well.

So, I have a repeater that has a list of items that I would like to assign task numbers as the rows are added ie: 1,2,3 etc. As I have facet filters running, I want numbers to stay assigned to those specific rows so if I run a filter it could return 2, 6, 14, 22, etc. instead of just counting the amount of rows.

I’m guessing that this will be some kind of expression within the repeater add row functionality.

Thank you!


#2

Hi!

It gets trickier if you are deleting rows as well. If not, it’s fairly straightforward to add the next number up.

You’d need to use a local variable referring to the repeater in the add row value so you can get its ItemCount, and then add one to it. The repeater here is named “rep” and I used the same name for the local variable that refers to it.


#3

[ Edit ]

If you are deleting rows, it’s easy enough to find out what the highest id number in the repeater is, and add 1 to that in the new row. You’d use the “listener” method to find the highest amount. Not documented, but Googlable (“axure repeater listener”) to search for the basic technique. I’m happy to assist with that.


#4

This method doesnt work. It achieves counting rows displayed, but I need the numbers to stay with the row they were created for. So if the user creates a row called apples and a row called oranges, then they get numbers 1 and 2, respectively. But if the user filters for oranges then the item that appears in the repeater has a 2 next to it and not a 1.


#5

Hi Comradeski!

I do see an error in my code: if you are currently filtered, the itemCount property refers to the number of rows currently not filtered out, rather than the total number of rows. For that you would want the property dataCount.

I’m attaching a sample. Note that the filter has some extra code to make sure that filtering is NOT case sensitive. You could use other code to handle partial matches, etc.

add row with new id.rp (63.8 KB)