How do I get the count of a repeat and use it as a condition?

Hi, I have an element that contains a bootstrap-generated table that could have between 0 and 5 rows. I would like to toggle the class of the element if the count of the repeat is 0. How would I set this condition for this class toggle?

Thanks!

If I got it right you should use “Modulus (Remainder)”. In this way, you can achieve the result you want.

{{ var1.value % var2.value == 0 ? true : false}} 

If you do it this way, danger class will be added on every 5th row.

<tr dmx-class:bg-danger="$index % 5 == 0 ? true : false"> text text text </tr>

You can write the conditions you want inline.

{{condition ? true : false}}

Hi @TGD,

You can use the count method on the array you are using in the expression of the repeat. On your class toggle just select that array, then use the formatters to select count. Then operation == 0.

Thank you so much @mebeingken!

Hey Alpaslan, it wasn’t exactly what I was looking for but this is a helpful tip I’ll keep in mind. Thanks!