2

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?

3
  • Plain old CSS tr:nth-child(odd) and tr:nth-child(even) is not sufficient? Dec 18, 2018 at 17:00
  • Sure, but how would I inject that on a modern list view? Jan 19, 2019 at 12:39
  • Unfortunately, I couldn't tell you. I'm still stuck on 2013/2016 on-prem. Jan 19, 2019 at 16:53

1 Answer 1

1

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','')"
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.