Question

I want to put track numbering in my views.List, is there any option for that or will I have to create a separate numbering and just put it in front of the list?

1. Title - Artist
2. Title - Artist
3. Title - Artist
etc

Thanks.

Was it helpful?

Solution

A List use a Collection object internally. You can access to the Collection with list.collection.

int numberTracks = list.collection.length;
for (int i=0; i<numberTracks; i++) {
    console.log(i + " " + list.collection.get(i));
}

another way,

list.collection.data.forEach(function(item, index) {
    console.log(index + " " + item);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top