C-Sharpcorner - Latest Articles: Hide Weekends In SharePoint Calendar View

来源:转载

SharePoint provides a calendar which can be used to track upcoming events and schedules. OOB calendar is quite powerful - It can be used to track deadlines, implement reminder alert, add workflow to achieve business logic, integrate with other OOB web parts and so on. By default the Calendar would be displayed as the following:

As you can see it even includes the weekends in the view which is by design. In one of the project requirements I had to hide the weekends from the view so that the users see only the week days.

Let’s see how to do it

First step is to set Monday as start date in the calendar view. In order to do this go to Site settings .

Click on Regional settings .

By default the first day of the week is set to Sunday.

Change first day of week to Monday.

Now the Saturday and Sunday columns would align towards the end the calendar. We can hide those using CSS.

In order to do this, from Site settings edit the calendar view page.

Add Content Editor Web Part (CEWP) to the calendar page as below:

From the CEWP, click on Edit Source and add the css to hide the calendar columns that correspond to Saturday and Sunday.

Place the following CSS on to the CEWP script window:

<styletype= "text/css" > table.ms-acal-month>tbody>tr>th:nth-of-type(1){ display:none!important; } table.ms-acal-month>tbody>tr>th:nth-of-type(7){ display:none!important; } table.ms-acal-month>tbody>tr>th:nth-of-type(8){ display:none!important; } table.ms-acal-month>tbody>tr>td:nth-of-type(6){ display:none!important; } table.ms-acal-month>tbody>tr>td:nth-of-type(7){ display:none!important; } </style>

On applying this CSS to the above calendar table we can hide the weekend columns.

Finally the calendar view shows only week days.

Thus we have seen how we can remove weekends from the default calendar view. This has been tested with both Share Point 2013 and 2016.



分享给朋友:
您可能感兴趣的文章:
随机阅读: