(SOLVED)Number the Items in Repeater (1. Item, 2. Item, 3. Item)

Hey Guys,
I´m trying to create a Ranking Table for a Football league.

the Teams listed are sorted by the amount of Points and Goals. Now i´m trying to add a ranking system but I´m lost.
I need a code that automatically numbers the items. So if a team is on 3 Place i need the repeater text element to say: “#3

In the end it should automatically show the current position of each team depending on the sort.

I apriciate your Help!

Add an onItemReady() function:
https://www.wix.com/corvid/reference/$w.Repeater.html#onItemReady
Inside it put:
$item(“#text1”).text = “#” + (index +1).toString();

Wow mate! Thank you! So easy x)

You’re welcome :slight_smile:

Hi Pavel, Would you mind sharing the code you used to accomplish the ranking? Thanks so much.

Hey alan,

Here’s how to do it:
first you’ll need a text on a repeater with the id of “#text1” (or whatever, just change it in the code)
then add an on ready for the dataset by clicking “onReady” on the Properties & Events panel . This will automatically add this on your code:

export function dataset1_ready() {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here:
 
 }

Then add this inside the the onReady

$w('#repeater1').onItemReady( ($item, itemData, index) => {
        $item("#text162").text = "#" + (index +1).toString();
    })

in total your code should look like this:

export function dataset1_ready() {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    $w('#repeater1').onItemReady( ($item, itemData, index) => {
        $item("#text1").text = "#" + (index +1).toString();
    })
}

DJ bon26