SOLVED

Sharepoint Conditional Formatting

Brass Contributor

Hi All,

I am trying to find Json code for SharePoint online 365 columns in a custom list:

 

If columnX = "no" make the column bold

 

TIA,

Joe

10 Replies
Hi, You probably need to use a Field Customizer for this (and that way no that it will work in modern pages as well as classic). A good write-up of the process is at: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-simple-field-cu... You will need to change the code in the onRenderCell to check for your "No" value and then add the appropriate style class. Cheers, Nigel

Thanks Nigel,

I will look into that.  I didnt expect it to be so complex.  I figured I could just add some Json Code in the coumn Formatting in the column settings.

 

Thanks again,

Joe

It might be possible to do something with the Column Formatting (Ive never really used it) but the Field Customizer is probably the best way to customize the rendering of any field, and be confident that it will work in Modern SharePoint pages
best response confirmed by Joe Fischer (Brass Contributor)
Solution

Hi Nigel,

Yes a small bit of Json in the column formatting does the trick :)

Below is an example, @faustocapellanjr sent me...

Thanks again for your help.

Joe

 

{
   "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
   "txtContent": "@currentField",
   "elmType": "div",
   "style": {
       "font-weight": {
           "operator": "?",
           "operands": [
               {
                   "operator": "==",
                   "operands": [
                       "@currentField",
                       "No"
                   ]
               },
               "bold",
               ""
           ]
       }
   }
}

nice one! Will have to look into what you can do with column formatting a little more
Thanks I will see what else I can play with :)

Rather than making a column bold, you may be able to achieve the same business requirement and draw attention to a value by changing the background color. This can be conditional set based on the value on a record (i.e Yes or No).

 

More recently, there is also a no-code solution for Choice, Date/Time, and Boolean column types that does not require knowledge of complex JSON to assign background colors.

No Code Column Formatting – SharePoint Online

Hi @matthew,

That is wonderful!!! 

 

Thank you so much for keeping track of this issue and responding!!

 

Thanks Agian,

Joe

 

 

@Joe Fischer 

 

Hi There...I know this post is several years old; however, Microsoft has granted your wish WITHOUT JSON CODE! The update is rolling out now and my tenant just got it last week! If you go into the view drop down, and select "Format this view" you will see 2 options. The 2nd option is for conditional formatting. All you have to do is just make sure the column by which you want the rule to run is showing up in the view. From there you can easily say...if this column equals "no" then make the entire row (or a particular column bold, red, italicized...whatever). Good luck and here is a link to the roadmap item

 

https://techcommunity.microsoft.com/t5/Microsoft-SharePoint-Blog/Content-collaboration-throughout-Mi...

1 best response

Accepted Solutions
best response confirmed by Joe Fischer (Brass Contributor)
Solution

Hi Nigel,

Yes a small bit of Json in the column formatting does the trick :)

Below is an example, @faustocapellanjr sent me...

Thanks again for your help.

Joe

 

{
   "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
   "txtContent": "@currentField",
   "elmType": "div",
   "style": {
       "font-weight": {
           "operator": "?",
           "operands": [
               {
                   "operator": "==",
                   "operands": [
                       "@currentField",
                       "No"
                   ]
               },
               "bold",
               ""
           ]
       }
   }
}

View solution in original post