HOME ABOUT
I AM HERE
  • Twitter icon
  • Facebook icon
  • Technorati icon
Bookmark and Share

Using JQuery to round averages in a SharePoint view

April 14, 2011 19:09 by Aidan

I had a question from a user asking whether it was possible to round the Average that is displayed on SharePoint views to 2.d.p.

Out of the box this is not possible but with a little bit of JQuery we can find the average and round it to the required d.p.

<script src="jquery.js"></script>
<script>
$(document).ready(function(){
   $('b').each(function(index){
   var value = $(this).html();
   var num = value.replace('Average = ','');
   var result = Math.round(num*Math.pow(10,2))/Math.pow(10,2);
   $(this).replaceWith('<b>Average = '+result+'</b>');
   });
});
</script>


Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed
blog comments powered by Disqus