Home › Forums › vLooup for SharePoint › Conditionally format vlookup progress bar
Tagged: vlookup progress bar
- This topic has 3 replies, 2 voices, and was last updated 6 years ago by Alexander Bautz.
-
AuthorPosts
-
-
October 22, 2018 at 20:42 #22596
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! -
October 23, 2018 at 19:05 #22610
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
- This reply was modified 6 years, 1 month ago by Alexander Bautz.
-
October 26, 2018 at 02:29 #22634
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?
-
October 26, 2018 at 13:40 #22640
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
-
-
AuthorPosts
- You must be logged in to reply to this topic.