Shade Alternating Rows in a Table

9 Likes

Thanks, that’s a great way to highlight rows. It will be especially useful in financial tables!

1 Like

wuau, this would be great if it would be a feature in coda! Unfortunately does not work when I reorder the row, right? :smiling_face_with_tear:

1 Like

Because of the way the formula is set up, what you see will always be zebra lines. But if the third row becomes the second row, it will change color, to the colour used for even rows.

1 Like

yes. you can reorder the rows and still haver alternating shading

Does not work for me! I think it’s because I use Groups on the felt side, no?

1 Like

Hello @Eva_Folch and others,

Coda does not give us programmatically access to the row number you see when activating or editing a table - if we would have access to those numbers, shading would be a very simple process.

But since we can’t do it the simple way, we have to resort to another solution in our conditional formatting code. The simplest is using the RowID (as illustrated earlier in this thread), but as most of you have noticed, as soon as you start inserting or deleting rows, the RowID is not producing the desired results.

A better way of doing the shading is by adding a column and filling it with rank(). It doesn’t solve all problems outright, but shading stays correct after deleting rows. inserting rows still makes a mess of your shading.

When grouping tables, you need a slightly different solution.

I have made a doc with a few solutions for different situations. Each solution works for a specific situation, but in most docs a view that is sorted or grouped in a specific way will be used in that configuration forever. The way Coda works requires you to adjust your formulas if sorting or grouping is changed.

To the best of my knowledge it is not easy to do correct shading when a filter is applied. I think it can be done by counting visible rows, but there will be quite some overhead - when I have some time I will investigate further.

1 Like

I added a new view to the same table (at the very bottom) to show that with some extra effort (see the explaining text at the top of the page) even a filtered table can have alternate row shading.

2 Likes

Same thing that happened to me