Conditionally format vlookup progress bar

Forums vLooup for SharePoint Conditionally format vlookup progress bar

Viewing 3 reply threads
  • Author
    Posts
    • #22596
      Kim
      Participant

      Hi, I would like to change the color of a vlookup progress bar, based on another column in the vlookup, e.g. Status, if status is Past Due, change the progress bar to red. I have looked at some different examples of code, but haven’t been able to figure out how to apply conditional formatting to the progress bar. Can you please advise how to apply conditional formatting to the progress bar?

      Also, on the vlookup where I have a row limit, the “Show More” button stretches across the entire form. Is there a way to resize this?
      Thanks!

    • #22610
      Alexander Bautz
      Keymaster

      To do this you must override the default progress bar settings. Use this in the Special configurations field:

      {"function":"customProgressBar"}

      And then add this to your Custom JS textarea:

      function customProgressBar(v, item){
          var val = parseInt(v * 100,10); // If it is a percentage complete column you must multiply it with 100
          var status = item.get_item("Status");
          var bgColor = "green";
          if(status === "Past Due"){
              bgColor = "red";
          }
          return "<div class='vLookupProgressBarOuter' style='width:100px;'><div class='vLookupProgressBarInner' style='background-color:"+bgColor+";color:black;width:"+val+"px;'> "+val+"%</div></div>";
      }

      Please note that you must have the Status column in the vLookup table for this to work. Also, ensure the field Status is the correct name of your field.

      Let me know how this works out.

      Alexander

    • #22634
      Kim
      Participant

      Alex, thank you! This looks beautiful in the form. However, when I show this on a list view, it doesn’t render as a progress bar. Is there something else I need to do for it to be a progress bar when I add the vlookup to a list view?

    • #22640
      Alexander Bautz
      Keymaster

      Unfortunately this code cannot be used in a list view. If you are on Office 365 you can use this method: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

      Alexander

Viewing 3 reply threads
  • You must be logged in to reply to this topic.