SharePoint: Color Coded Calendars in MOSS
Here is a good sample code
Can a calendar display in colors?
I have been asked a few times if the SharePoint calendar can display
items in color. It turns out this is not too hard to do. The basic steps
are:
By
AlpesH Shah
Can a calendar display in colors?
I have been asked a few times if the SharePoint calendar can display
items in color. It turns out this is not too hard to do. The basic steps
are:
- Add a column to the calendar list to pick the color
- Add a calculated column to create the HTML to display the color. This can be done with HTML or CSS. This example uses "<FONT COLOR=".
- Add the new column to the view
- SharePoint will convert the "<" character into "<" so we need to add a little JavaScript to convert it back. The easiest way to add the JavaScript is with a Content Editor Web Part
- Create or open a calendar
- Add a new column named "Color" (Settings, List Settings) – most likely type will be "Choice" with choices like "Red, Green, Blue, Black", but this could be a lookup or a single line of text.
(See here for an HTML color chart: http://www.w3schools.com/html/html_colornames.asp)
- Add a new column named "CalendarText"
- Modify the existing view, or create a new view such as "Color Calendar"
- Add a Content Editor web part
- Site Actions, Site Settings, Edit Page
- Add a Content Editor web part and move it below the calendar web part
- Click in the web part click Edit, Modify Shared Web Part
- Click Source Editor
- Site Actions, Site Settings, Edit Page
- Paste this JavaScript:<script type="text/javascript" language="javascript">
var x = document.getElementsByTagName("TD")
var i=0;
....
....
Click here to view the full article
No comments:
Post a Comment