none
Alter Sharepoint 3.0 Monthly Calendar View

    Question

  • I would like to alter the view of the monthly calendar to display the start and end time of an event. The default view is displaying the start time and the event title.

     

    Example:

    3:00PM

    Meeting

     

    I would like the view to show:

    3:00PM-4:00PM

    Meeting

     

    Tuesday, May 29, 2007 8:39 PM

Answers

  • Hi,

     

    What you need to do (which will overide all calendars rather than that particular one) is open up the Calendar Control template. This is within the folder c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Templates\Control Templates.

    Open up the file DefaultTemplates.ascx file

     

    At around Line 2477 you will see the following section:

     

    <SharePoint:RenderingTemplate ID="CalendarViewMonthItemTemplate" runat="server">

    ....

    </SharePoint:RenderingTemplate>

     

    This is the default template for rendering the calendar items on the monthly view. You can add/edit what ever you like here, but to add the end time you need to replace the template with the following code..

     

    <Template>
     <table border=0 cellspacing=0 cellpadding=0 dir="<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.Direction",""))%>">
     <tr>
     <td class="ms-cal-monthitem">
       <a onfocus="OnLink(this)"
      href="<%# SPHttpUtility.HtmlUrlAttributeEncode(DataBinder.Eval(Container,"DataItem.DisplayFormUrl",""))%>?ID=<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.ItemID",""))%>"
      ONCLICK="GoToLink(this);return false;" target="_self"
     tabindex=<%# DataBinder.Eval(Container,"TabIndex")%>
     >
      <NOBR>
      <b><%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DateTimeString","{0:G}"))%> -  <%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%></b></NOBR><br>
     
      <%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.Title","{0:G}"))%>
      </a>
      </td></tr></table>
     </Template>

     

    The only change here is adding the EndDate (<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%></<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%>)

     

    We have rolled this out on to our live system so 100% sure it works now... Thanks!

    Wednesday, June 20, 2007 2:46 PM

All replies

  • Sorry, I don't have an answer. I have a similar question. For recurring events, the End Time of the Calendar View shows the maximum year, 2099, date and time. How do I set the End Time to show only the time of day the event ends? Thanks.

     

    Thursday, May 31, 2007 7:05 PM
  • To customize the view you can use SharePoint Designer and change the webpart to a XSLT view. Doing this you can modify the view the way you want. You can choose wich valuables you want to show and where you want to show them. Im sure its possible to do what you guys need.

    You can change the webpart to xslt by selecting it in sharepoint designer right click -> convert to XSLT view or something simular.
    Friday, June 01, 2007 8:01 AM
  • Hi,

     

    What you need to do (which will overide all calendars rather than that particular one) is open up the Calendar Control template. This is within the folder c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Templates\Control Templates.

    Open up the file DefaultTemplates.ascx file

     

    At around Line 2477 you will see the following section:

     

    <SharePoint:RenderingTemplate ID="CalendarViewMonthItemTemplate" runat="server">

    ....

    </SharePoint:RenderingTemplate>

     

    This is the default template for rendering the calendar items on the monthly view. You can add/edit what ever you like here, but to add the end time you need to replace the template with the following code..

     

    <Template>
     <table border=0 cellspacing=0 cellpadding=0 dir="<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.Direction",""))%>">
     <tr>
     <td class="ms-cal-monthitem">
       <a onfocus="OnLink(this)"
      href="<%# SPHttpUtility.HtmlUrlAttributeEncode(DataBinder.Eval(Container,"DataItem.DisplayFormUrl",""))%>?ID=<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.ItemID",""))%>"
      ONCLICK="GoToLink(this);return false;" target="_self"
     tabindex=<%# DataBinder.Eval(Container,"TabIndex")%>
     >
      <NOBR>
      <b><%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DateTimeString","{0:G}"))%> -  <%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%></b></NOBR><br>
     
      <%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.Title","{0:G}"))%>
      </a>
      </td></tr></table>
     </Template>

     

    The only change here is adding the EndDate (<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%></<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%>)

     

    We have rolled this out on to our live system so 100% sure it works now... Thanks!

    Wednesday, June 20, 2007 2:46 PM
  • Hi,

     

    Is there any way to modify the default Month view of a calendar to start on a Monday rather than Sunday?

     

    Any help is GREATLY appreciated.

     

    TIA,

    Justin Stumpf

    Friday, June 29, 2007 5:47 PM
  • Yes, you can edit your workweek by going to the top site and go to the site configuration. At the site configuration you can edit your Regional setup. There you can change the starting day of the week and lots of oter stuff.
    Monday, July 02, 2007 9:34 AM
  •  ajpion wrote:

    I would like to alter the view of the monthly calendar to display the start and end time of an event. The default view is displaying the start time and the event title.

     

    Example:

    3:00PM

    Meeting

     

    I would like the view to show:

    3:00PM-4:00PM

    Meeting

     

     

    Create a calculated column using whatever combination of the other fields and punctuation you like. e.g. [Start Time] & " - " & [End Time] Then make that calculated column the Month View Title or Week View Title or whatever.

    Monday, July 02, 2007 9:44 AM
  • WOW, I cannot believe I missed that one! Thanks for the help all, I appreciate it!

     

    Changing the first day of the work week did the trick, now all business calendars begin on a monday like they should...

     

    TA,

    JUstin Stumpf

    Monday, July 02, 2007 2:29 PM
  • hi,
    i am trying to show only from monday to friday at calendar view.
    i have ticked the days from reginal settings but it doesn't seem doing anything.
    Do you know how to do this?
    Thanks
    Tuesday, July 03, 2007 2:05 AM
  • So how do you change the month view title to reflect the column of your choosing?
    Thursday, July 05, 2007 11:03 PM
  • I have a question.. Maybe someone out there can help. I would like to have multiple date ranges added. Right now I can only add one start and end date and would like to have two. I would aslo like to be able to put in more then one refrence for an item such as. The Name and the ID,  and what date range it refrences Such as Hardware delivery date is the one search date range I want and the other is Integration date.. If there is anyone out there who can think of how to alter the montly calendar view to do this.. You will be my new best friend. I have tried just adding a new lookup and it didn't work. If I add another webpart it puts a 2 calendar views on one page instead of it being one.

     

    Thanks,

     

    CarrieAnn

    Thursday, August 30, 2007 8:53 PM
  • This is exactly what we were looking for, but unfortunately I cannot get this to work.  I took what you have here and copied it and replaced that section of this file and yet it is still not working.  Is there something else I need to do with this?  I also had a question about what you typed at the end of your post:

     

    The only change here is adding the EndDate (<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%></<%# SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"DataItem.EndDate","{0:t}"))%>)

     

    This seems to be the same line written twice, but I only see it once in your longer portion outlining what needs to be here, which one is correct?

    Wednesday, September 26, 2007 7:11 PM
  • I have tried both methods - first to create a calculated column - that solution gave me a decimal number even though I selected date/time format.

    The second solution to modify the defaulttemplates.ascx file with the modified code - did not produce any changes.

    Any other ideas of how to get the end time to show on the calendar?

    Tuesday, October 02, 2007 4:14 PM
  • Did you "iisreset" after changing the ascx file?  You have to do that for the changes to take effect.

    Wednesday, October 03, 2007 1:07 AM
  • Actually I rebooted the entire server.  Other than replacing that section of code in the defaulttemplates.ascx file - are there any other changes I need to make to get this to work?

    Wednesday, October 03, 2007 7:44 PM
  • But when you use the calculated field and display that in the different column views you still see the start time - so if you can't display the end time in sharepoint how do you get rid of the start time so only your calculated column shows.

     

    Example:

    3:00PM

    3:00PM-4:00PM

    Meeting

    Wednesday, November 07, 2007 7:02 PM
  • great post, the defaultTemplate change worked like a charm.

     

    thanks!

    Wednesday, November 07, 2007 10:09 PM
  • If you made a copy of defaulttemplates.ascx and this copy is in the same folder, the copy will override defaulttemplates.ascx! So move your copy to another backup folder if you do have this in the same folder as defaulttemplates.ascx. hope this helps you!

     

     

     DLMosser wrote:

    Actually I rebooted the entire server.  Other than replacing that section of code in the defaulttemplates.ascx file - are there any other changes I need to make to get this to work?

    Wednesday, November 28, 2007 11:58 AM
  •  

    I really need to discover how to do this

    how do we customize a shareoint calendar to read 5 days a week

    Wednesday, February 20, 2008 3:41 PM
  • Thanks, this is great! I used it to do something slightly different: take out the time which shows up above the item even when you're just using a date (shows up as "12:00 AM" and is completely misguiding!) Your solution worked perfectly for this.

    My only problem is this: I only want to use this format (not showing the time) for one calendar view I don't want this to affect other calendars that people are using in case they want to display the time.

    I tried using custom names for the altered templates:

    E.g. change Template=&amp;#39;CalendarViewmonthChrome&amp;#39; to Template=&amp;#39;CustomCalendarViewmonthChrome&amp;#39;

    and then change <SharePoint:RenderingTemplate ID="CalendarViewMonthItemTemplate" runat="server"> to <SharePoint:RenderingTemplate ID="CustomCalendarViewMonthItemTemplate" runat="server">

    but this gives an unspecified error when I  load the page.

    Any ideas on  isolating the customizations to just one view or list?

    Thanks!

    Paul
    Thursday, March 06, 2008 8:21 PM
  • hi,

       Thanks.I have a doubt in monthly calendar view,Instead of startdate can i show the foldername in calendarview?if possible how to show? 

     

    Monday, March 24, 2008 6:00 AM
  • LewisBenge... thank you thank you very much!
    Tuesday, September 09, 2008 3:22 PM
  • This Solution is Really Great it is working well.
    How to alter the month view if i want to display other Custom columns?

    Thanks in advance.

    Tuesday, November 04, 2008 12:16 PM
  • Apart from the title of the Task Is it possible to show the Created By user name or Modified By user name in Month View of a Calendar in SharePOint 2007
    Thanks, Binu Raj V, binu.vengattu@ust-global.com
    Monday, April 19, 2010 11:57 AM
  • Worked like a charm for me.  Thanks!
    Monday, November 29, 2010 6:24 PM
  • Can anyone guide me how to change Calender view to show Attached files instead of "Title"

    I wanted to reduce one hop to When user click directly to attachments from calender view.

    current calender : shows title & when clicked takes to dispform.aspx & from thier navigate to attached file! which takes two hops..

    Thanks in advance.

    PrashanthSparks

    Saturday, March 03, 2012 12:48 PM