Need a ranking in my RepeatingPanel

What I’m trying to do:
Display a score overview inside a RepeatingPanel. The basics work, i.e. I am able to see the name from the DB and it’s corresponding score. Where I’m struggling is to rank the data. I’d like to show not just the name and it’s score, but also its rank in the table, starting at 1 and counting up.

What I’ve tried and what’s not working:
I’ve tried dumping the data in a new array and using enumerate to add a ranking but that seems like a workaround. There must be a simpler way.

Code Sample:

 table = app_tables.ploegen.search()
    self.repeating_panel_1.items = table

If what you are trying to preserve is the “lazy” loading of the search iterable instead of loading all of the items into memory and then putting them into the repeating panel items, then I usually use a generator comprehension for that.
So:

table = app_tables.ploegen.search()
self.repeating_panel_1.items = ( { 'rank' : i , **x }
                                       for i, x in enumerate(table, start=1) )
4 Likes