Add the calculated column "colorCalendar" in sharePoint calendar list, and paste the following in the formula field :
="<div style='width:100%;background-color:"&IF(Category="meeting","#4FDB51",IF(Category="work hours","#F08616",IF(Category="holiday","#F55875",IF(Category="gifts","#F558D5",IF(Category="A","#9932CC",IF(Category="B","#FFD700",IF(Category="C","#00FF00",IF(Category="D","#FAF0E6",IF(Category="E","#FF00FF",IF(Category="F","#CD853F",IF(Category="G","#BC8F8F",IF(Category="H","#008080",IF(Category="I","#FFFF00",IF(Category="J","#9ACD32",IF(Category="K","#F5F5F5",IF(Category="L","#A52A2A",IF(Category="anniversary","#DC143C",IF(Category="get-together","#E0F558",IF(Category="birthday","#6E80FA","#FF4040")))))))))))))))))))&";'> "&Title&"</div>"
The possible nested if else conditions in SharePoint 2010 is 19, all those profiles which says it is less than this are wrong. This calculated field working great at my end
Go to Calendar View and set "colorCalendar" for the month view title, week view title and day view title.
Now add a content editor web part in the calendar page and paste the following script to change color background color of calendar events :
<style> .ms-acal-time { DISPLAY: none } .ms-acal-selected { PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: 0% 50%; PADDING-TOP: 0px } .ms-acal-item { PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: 0% 50%; PADDING-TOP: 0px } .ms-acal-sdiv SPAN { MARGIN-LEFT: 0px } .ms-acal-sdiv DIV.ms-acal-title SPAN { MARGIN-LEFT: 0px } .ms-acal-rootdiv DIV { PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 100%; PADDING-TOP: 0px }</style> <script> // Color coded calendars for SharePoint 2010 // load our function to the delayed load list _spBodyOnLoadFunctionNames.push('colorCalendarEventLinkIntercept'); // hook into the existing SharePoint calendar load function function colorCalendarEventLinkIntercept() { var OldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4a; SP.UI.ApplicationPages.CalendarNotify.$4a = function () { OldCalendarNotify4a(); colorCalendarEventLinks(); } } // hide the hyperlinks function colorCalendarEventLinks() { // find all DIVs var divs = document.getElementsByTagName("DIV"); for (var i=0;i'); divs[i].title = divs[i].title.substring(0, divs[i].title.indexOf('<')) + divs[i].title.substring(divs[i].title.indexOf('>')+1, divs[i].title.lastIndexOf('<')); } // find "x more items" links and re-remove links on Expand/Contract if (divs[i].className.toLowerCase()=="ms-acal-ctrlitem") { var links = divs[i].getElementsByTagName("A"); if (links.length==1) { links[0].href="javascript:colorCalendarEventLinks();void(0);" } } } }</script>
hello
ReplyDeleteplz tell me how can start learn sharepoint with practical work plz let me know
thanks
Hi,
DeleteHave a look into the links here: http://deepaksemwalsp.blogspot.in/2012/04/list-of-sharepoint-2010-training-videos.html
Not working for me. When I add a new event, the div/style code is inserted along with the Title. No color.
ReplyDeletePlease check the service pack installed on your SharePoint farm, if it is service pack 1 then please change $4a to $4b in the script.
DeleteI have tried the coding and it is also still showing the div/style code inserted along with the title color. I also changed the $4a to $4b. Is they something else I need to change.
ReplyDelete