Forum Discussion

Joe Fischer's avatar
Joe Fischer
Brass Contributor
Jan 29, 2018
Solved

Sharepoint Conditional Formatting

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

  • Joe Fischer's avatar
    Joe Fischer
    Jan 31, 2018

    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",
                   ""
               ]
           }
       }
    }

10 Replies

  • pnthrzrule's avatar
    pnthrzrule
    Iron Contributor

    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-Microsoft-365-Ignite-2019/ba-p/960868

  • 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.

    https://www.technologytobusiness.com/microsoft-sharepoint/no-code-column-formatting-sharepoint-online

    • Joe Fischer's avatar
      Joe Fischer
      Brass Contributor

      Hi matthew,

      That is wonderful!!! 

       

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

       

      Thanks Agian,

      Joe

       

       

  • 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-customizer 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
    • Joe Fischer's avatar
      Joe Fischer
      Brass Contributor

      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

      • Nigel Witherdin's avatar
        Nigel Witherdin
        Iron Contributor
        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

Resources