Skip to content

Instantly share code, notes, and snippets.

@tecchan1107
Last active May 10, 2024 22:39
Show Gist options
  • Save tecchan1107/d5c1fc20e68f8e5bb5ea2ce1d702eb36 to your computer and use it in GitHub Desktop.
Save tecchan1107/d5c1fc20e68f8e5bb5ea2ce1d702eb36 to your computer and use it in GitHub Desktop.
Sample column formatting to display as many choices as Max. Reference:https://github.com/pnp/List-Formatting/tree/master/column-samples/multi-choice-bulleted-numbered-list
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "column",
"justify-content": "flex-start",
"flex-wrap": "wrap",
"margin": "5px 0px"
},
"children": [
{
"elmType": "div",
"forEach": "choiceIterator in @currentField",
"style": {
"margin": "3px 0px",
"display": "=if(loopIndex('choiceIterator')+1<=[$Max],'flex','none')",
"flex-direction": "row",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"style": {
"margin-right": "5px"
},
"attributes": {
"iconName": "FavoriteStarFill"
}
},
{
"elmType": "div",
"txtContent": "[$choiceIterator]"
}
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment