Json Formatting
-
08-02-2021 - |
Вопрос
I am in a position where all I want to do is change the font color of a column to #002c77
no matter what the text within the text field says. I cannot for the life of me get it to work, and there I am sure I am doing something wrong.
until now I have it like this and it does not work
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$Stadie] == 'Stadie 1 - Påbegyndt', '#002c77',
if([$Stadie] == 'Stadie 2 - Påbegyndt', '#002c77',
if([$Stadie] == 'Stadie 3 - Påbegyndt', '#002c77',
if([$Stadie] == 'Stadie 4 - Påbegyndt', '#002c77',
if([$Stadie] == 'Completed', '#002c77')))))"
}
}
And previously I tried this:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style":{
"color":{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField", "Stadie 1 - Påbegyndt",
{
"operator": "==",
"operands": [
"@currentField", "Stadie 2 - Påbegyndt"
]
},
"#002c77",
""
]
},
"#002c77",
""
]
}
}
}
But it only seemed to work with the first one and not the ones after, anyone know how to format the text within a field no matter what it says so that the font color is changed to #002c77
?
Thanks in advance.
Решение
Try using below JSON Code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "#002c77"
}
}
Official documentation: Use column formatting to customize SharePoint.
Output:
Не связан с sharepoint.stackexchange