Text Wrapping using JSON
-
08-02-2021 - |
質問
I am new to this forum.
I have a list that has a choice field with about 20 options (each varying in length). I want to display each choice on a new line (text wrap).
Default View looks like this>
I would prefer it to look like this:
I heard that JSON formatting on the column might be able to achieve this but I have never used that before.
If you need more information let me know. Any help would be appreciated.
解決
As you are using SharePoint Online, you can try using anyone of the below:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=join(@currentField, '\n')"
}
Reference: Organize multi-choice user inputs by separate line (not comma)
OR
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "block",
"width": "100%"
},
"forEach": "choice in @currentField",
"txtContent": "[$choice]"
}
]
}
Reference: Rendering multi-value Choice fields vertically using JSON Column Formatting
Official documentation: Use column formatting to customize SharePoint
他のヒント
You could try this:
{
"$schema":
"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=join(@currentField, '\n')"
}