Changing the Color of a Row in a SharePoint List (using JSON) based on a columns value
-
21-02-2021 - |
Pregunta
So I have a SharePoint list with a column called modified. I used the following code to change the rows colors based on when it was last modified which works fine:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now - 86400000, 'sp-field-severity--blocked', if([$Modified] < @now && [$Modified] >= @now - 259200000, 'sp-field-severity--warning' , ''))"
}
However, now I want it to be a dark grayish color instead of red. I have tried many different things, but cannot get it too work for some reason.
Solución
Try something like below:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now - 86400000, 'ms-bgColor-gray120', if([$Modified] < @now && [$Modified] >= @now - 259200000, 'sp-field-severity--warning' , ''))"
}
This will apply ms-bgColor-gray120
class for first condition ([$Modified] < @now && [$Modified] >= @now - 86400000
).
Similarly, you can apply any of the predefined classes given in below links as per your requirements:
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange