SharePoint Hide Time in Calendar View

SharePoint Hide Time in Calendar View

In this article we can explore a SharePoint Page Customization scenario. Please note that this falls into the responsibility of a SharePoint Designer.

modifaction-in-sharepoint.png

The following are the tools that we use for the modification:

  • SharePoint Designer 2010
  • Internet Explorer

 sharepoint-designer.jpg

What is Calendar View?

Calendar View is a visual way of viewing documents or list items based on a Date column. We can enable Calendar view for a Library as well as a List.

Create a new Document Library

For this article, create a new Document Library and name it "My Calendar Docs".

create-document-in-sharepoint.png

Add some documents to the Library.

Now create a new Calendar view for the library above using "Library" > "Create View" button.

 choose-a-view-folder-in-sharepoint.png

Set the calendar properties as shown below.

 month-view-tile-in-sharepoint.png

 inote-in-sharepoint.png

The calendar has the following views:

  1. Month View
  2. Week View
  3. Day View

Each view can be displayed using the respective buttons from the Calendar View.

 library-tools-window-in-share-point.jpg

The following is our library after enabling the Calendar View.

 calender-tools-in-share-point.png

The Challenge

You can see the Time is displayed in the Calendar Item. Our challenge is to hide the Time part, which is not configurable in the usual way.

Let us see how to do this.

Open in Internet Explorer

Open the Calendar View in Internet Explorer & select "Tools" > "Developer Tools". In the dialog that appears click the Left Arrow as shown below.

 my-calender-docs-in-sharepoint.png

Now hover the mouse over the Calendar control and you will get the Time div highlighted.

modification2-in-sharepoint.png 

Inside the Developer Tools dialog, you can see the HTML elements as shown below.

 html-code-in-sharepoint.png

The div class name is ms-acal-sdiv and there is a Text element denoting time.

The above HTML elements are contained in the Calendar View.aspx page. We can edit this page using SharePoint Designer.

Open SharePoint Designer

Choose the "Site Actions" > "Edit in SharePoint Designer" to continue. If you do not have SharePoint Designer installed you need to install it first.

Inside SharePoint Designer, navigate to "Lists and Libraries, My Calendar Docs, Calendar View".

list-and-library-in-sharepoint.png 

We are editing the Calendar View page now.

calender-view-page-in-sharepoint.png

Click the Advanced Mode button from the tool bar. Now locate the following section as given below (you can refer to the line number as well):

 locate-section-in-sharepoint.png

Below the last line, add the following section.

.ms-acal-sdiv{
margin-left:-50px;
}

Now the entire section looks as in the following:

 entire-section-in-sharepoint.png

Now save the changes and you can refresh the page in the browser. You should get the Time part hidden as shown below.

 time-part-in-sharepoint.png

You can even change the color of the Div using the following code:

.ms-acal-sdiv{
background-color:aqua;
}

After the modification, refresh your browser window.

 site-action-in-sharepoint.png

You will see that the background color of the calendar changed.

 inote-in-sharepoint.png

We are pushing the text to the left side, instead of hiding it. Depending on the scenarios we can perform various solutions as:

  1. Hiding the div using display: none
  2. Changing color of div
  3. Setting Text to empty

DIV Id & Class

Please note that the DIV Id & DIV Class is different. The Id will be targeting a unique element but Class will be targeting a set of elements.

In our example we were targeting the DIV Class so that multiple elements will be targeted for the change to be applied.

 inote-in-sharepoint.png

Customizing Pages decreases Page Performance & might impact your SharePoint Governance rules. I recommend you consult with your SharePoint Administrator before performing such customization of pages.

References

http://bit.ly/WstBp

Summary

In this article we have seen how to use the SharePoint Designer to edit an existing Calendar page. In real-world scenarios this knowledge would be useful.