Skip to content

Commit c4f53a8

Browse files
authored
Update view-calendar-formatting.md
1 parent e7f8aa8 commit c4f53a8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/declarative-customization/view-calendar-formatting.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,30 @@ Groups the command bar customization options. For details on `commandBarProps`,
1515

1616
## See also
1717
- [Command bar customization syntax reference](./view-commandbar-formatting.md)
18+
19+
### Conditional view formatting based on a specific column
20+
21+
The following image shows an example of conditional formatting applied to a calendar view, based on a single choice column named **PROJECT**:
22+
23+
![SharePoint list calendar formatting](../images/calendar-view-formatting.png)
24+
25+
In this example, **PROJECT** column has the following options:
26+
- Project A
27+
- Project B
28+
- Project C
29+
- Project D
30+
- Project E
31+
32+
The JSON code below makes use of SharePoint Online Modern UI classes to apply colors, borders and a hover effect through the [Excel-style expression syntax](./formatting-syntax-reference.md#excel-style-expressions):
33+
34+
```JSON
35+
{
36+
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/calendar-formatting.schema.json",
37+
"additionalEventClass": "=if([$PROJECT] =='Project A' && @isSelected == false, 'sp-css-backgroundColor-successBackground50 sp-css-color-BlackText sp-css-borderColor-GreenText ms-bgColor-sharedGreenCyan10--hover ms-fontColor-white--hover', if([$PROJECT] =='Project A' && @isSelected == true, 'ms-bgColor-green sp-css-color-WhiteText', if([$PROJECT] =='Project B' && @isSelected == false, 'sp-css-backgroundColor-BgPeach sp-css-color-BlackText sp-css-borderColor-RedText ms-bgColor-sharedRed10--hover ms-fontColor-white--hover', if([$PROJECT] =='Project B' && @isSelected == true, 'sp-css-backgroundColor-redDark sp-css-color-WhiteText', if([$PROJECT] =='Project C' && @isSelected == false, 'sp-css-backgroundColor-BgGold sp-css-color-BlackText sp-css-borderColor-BrownText ms-bgColor-yellow--hover ms-fontColor-white--hover', if([$PROJECT] =='Project C' && @isSelected == true, 'ms-bgColor-sharedOrange10 sp-css-color-BlackText', if([$PROJECT] =='Project D' && @isSelected == false, 'ms-bgColor-communicationTint20 sp-css-color-BlackText sp-css-borderColor-BlueText ms-bgColor-sharedCyanBlue10--hover ms-fontColor-white--hover', if([$PROJECT] =='Project D' && @isSelected == true, 'sp-css-backgroundColor-BlueText sp-css-color-WhiteText', if([$PROJECT] =='Project E' && @isSelected == false, 'sp-css-backgroundColor-BgLilac sp-css-color-BlackText sp-css-borderColor-DarkPurpleText ms-bgColor-sharedBlueMagenta20--hover ms-fontColor-white--hover', if([$PROJECT] =='Project E' && @isSelected == true, 'sp-css-backgroundColor-BgPurple sp-css-color-WhiteText', if(@isSelected == false, 'sp-css-backgroundColor-neutralBackground20 sp-css-color-BlackText ms-bgColor-neutralTertiaryAlt--hover ms-fontColor-black--hover', 'sp-css-backgroundColor-neutralTertiary sp-css-color-WhiteText')))))))))))"
38+
}
39+
```
40+
<br>
41+
42+
The gif image below shows the final result:
43+
44+
![SharePoint list calendar formatting result](../images/calendar-view-formatting-result.gif)

0 commit comments

Comments
 (0)