Step
1:
- Create list
with my "progressBarList
"
- Create column with name Progressbar ,column type number
Step
2:
Create
calculate column with name "CustomProgressBar
"
Set
in formula: ="---"&[Progressbar]
Step
3:
- Edit list
page
- Add form
web part to this page
- Put the
code below in form web part source or download from here
<script>
// run on tr with
class '.ms-vb2; in '.ms-listviewtable' class
$(".ms-listviewtable tr
.ms-vb2").each(function(){
//chack if
current td innet text contain custom value like '---'
if($(this).text().indexOf("---")!=-1)
{
// split by
uniq value '---'
var temp=$(this).text().split("---");
//temp[1] contain the value
//set background color green if value is grther then 65
if(temp[1]>65){
$(this).html('<div
style="color:#ffffff;background-color:#2e983d;width:'+temp[1]+'px;
padding-top:3px; text-align:
center;"><b>'+parseInt(temp[1])+'%</b></div>')
}
//set background color yellow if
value is between 33 until 65
if(temp[1]>=33&&temp[1]<=65){
$(this).html('<div
style="color:#ffffff;background-color:#fecf3c;width:'+temp[1]+'px;
padding-top:3px; text-align:
center;"><b>'+parseInt(temp[1])+'%</b></div>')
}
//set background color red if
value is between 0 until 33
if(temp[1]<33&&temp[1]>0){
$(this).html('<div
style="color:#ffffff;background-color:#ee421b;width:'+temp[1]+'px;
padding-top:3px; text-align: center;"><b
color="white">'+parseInt(temp[1])+'%</b></div>')
}
// set 'No
Tasks' if is blank
if(temp[1]=="")
$(this).html('<div>No
Tasks</div>')
}
});
</script>
Result:
Very handy thanks
ReplyDeletethis is not working in SP2013...
ReplyDeleteHi Michele,
ReplyDeleteits work perfect try to surround this with
$( document ).ready(function() {
//code will be here
});
Hi, i from Brazil, put the code on my Sharepoint 2013 but not working
ReplyDeleteSorry my english
hi diago ,
ReplyDeletetry to run this code on developer tool (F12)
the best waty to put java script code on page :
1. save the code as txt file
2. upload the file to style library folder
3. add content editor web part to page
4. put the url in content editor in property of web part
* add jquery refrance if necessary
hope it's help
You can use SharePoint List Booster to add progress bars to your list or document libraries. Check it out at http://www.spbooster.com
ReplyDelete