Forum Discussion
Column formatting using JSON
Hi Alan Trafford,
That project is a web part that gives you a friendly interface to build the JSON for column formatting. It also contains a wizard :)
Give it a try :)
Joel
I saw a demo of it on https://www.youtube.com/watch?v=UuBytfAz3g4. It looks really good. That said, I'm still trying to avoid coding unless I have to. I think I'll be using Tomislav Karafilov workaround, as it's easy to apply.
Alan
- Nigel WitherdinFeb 05, 2018Iron Contributor
Hey,
Really good write up of what you can achieve with Column Formatting here: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting
Doesn't look like there is a "like" type operator to do partial string matching / substring matching, so I am guessing you would have to either:
- specify each of the possible "On Hold - <hold reason>" values in the JSON
- in your list have a field for the value "On Hold" and a separate field for the reason
Good luck!
- Alan TraffordFeb 06, 2018Brass Contributor
That's what I did in the end. The owner of the list did not want a new columns added, so I could not use Tomislav Karafilov solution. In case it will help others, here's my final code:
{ "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json", "debugMode": true, "elmType": "div", "attributes": { "class": { "operator": "?", "operands": [ { "operator": "&&", "operands": [ { "operator": "<=", "operands": [ "[$Finish]", "@now" ] }, { "operator": "||", "operands": [ { "operator": "==", "operands": [ "[$Status]", "Status1" ] }, { "operator": "==", "operands": [ "[$Status]", "Status2" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 1" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 2" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 3" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold" ] } ] } ] }, "sp-field-severity--blocked", "" ] } }, "children": [ { "elmType": "span", "style": { "display": "inline-block", "padding": "0 4px" }, "attributes": { "iconName": { "operator": "?", "operands": [ { "operator": "&&", "operands": [ { "operator": "<=", "operands": [ "[$Finish]", "@now" ] }, { "operator": "||", "operands": [ { "operator": "==", "operands": [ "[$Status]", "Status1" ] }, { "operator": "==", "operands": [ "[$Status]", "Status2" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 1" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 2" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold - 3" ] }, { "operator": "==", "operands": [ "[$Status]", "On Hold" ] } ] } ] }, "Error", "" ] } } }, { "elmType": "span", "txtContent": "@currentField" } ] }