I have been looking into using view formatting to alternate the colors of rows in order to recreate what came out of the box in the classic views. However it seems like I can't access the row ID as a criteria nor can I use Mod as an operator. I kinda found a work around using a calculated column to do the MOD, but it is not an elegant solution. Is there really no easy way to alternate the row colors?
1 Answer
All Items, Format current view, put the following in the JSON box.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if(@rowIndex % 2 == 0,'ms-bgColor-themeLighter ms-bgColor-themeLight--hover','')"
}
-
Yup, a few weeks after I requested it thechriskent returned with news that both rowid and MOD is now available :thechriskent.com/2019/02/20/… Mar 27, 2019 at 20:48
tr:nth-child(odd)
andtr:nth-child(even)
is not sufficient?