Can any one provide solution to disable Saturday and Sunday from SharePoint 2010 Calendar. I know there are some solutions for 2007. But I am looking for SharePoint 2010.
Thanks.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityCan any one provide solution to disable Saturday and Sunday from SharePoint 2010 Calendar. I know there are some solutions for 2007. But I am looking for SharePoint 2010.
Thanks.
jquery is your friend.
add a content query webpart. and add the code here: http://social.technet.microsoft.com/Forums/sharepoint/en-US/978d1104-d03a-4da7-a384-12a6bfddf6ca/remove-saturday-and-sunday-from-calendar-view-in-sharepoint-foundation-2013?forum=sharepointgeneral
of course jquery needs to be imported first, usually in your master page, or if its only for that page, then with a script/code web part too
Use below script
<script type="text/javascript">
$(document).ready(function(){
var oTable = document.getElementsByTagName("table");
if (oTable != null) {
for (i = 0; i < oTable.length; i++)
{
var table = oTable.item(i);
if (table.className == "ms-acal-month")
{
for (var c = 0; c < table.rows.length; c++)
{
if (table.rows[c].cells.length == 8)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
table.rows[c].cells[7].style.display = "none";
}
else if (table.rows[c].cells.length == 7)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[6].style.display = "none";
}
else if (table.rows[c].cells.length == 6)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[5].style.display = "none";
}
else if (table.rows[c].cells.length == 2)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
}
}
}
}
}
});
function month(){
var oTable = document.getElementsByTagName("table");
if (oTable != null) {
for (i = 0; i < oTable.length; i++)
{
var table = oTable.item(i);
if (table.className == "ms-acal-month")
{
for (var c = 0; c < table.rows.length; c++)
{
if (table.rows[c].cells.length == 8)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
table.rows[c].cells[7].style.display = "none";
}
else if (table.rows[c].cells.length == 7)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[6].style.display = "none";
}
else if (table.rows[c].cells.length == 6)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[5].style.display = "none";
}
else if (table.rows[c].cells.length == 2)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
}
}
}
}
}
}
//For week view
function week(){
var oTable = document.getElementsByTagName("table");
if (oTable != null) {
for (i = 0; i < oTable.length; i++)
{
var table = oTable.item(i);
if (table.className == "ms-acal-detail")
{
for (var c = 0; c < table.rows.length; c++)
{
if (table.rows[c].cells.length == 8)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
table.rows[c].cells[7].style.display = "none";
}
else if (table.rows[c].cells.length == 7)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[6].style.display = "none";
}
else if (table.rows[c].cells.length == 6)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[5].style.display = "none";
}
else if (table.rows[c].cells.length == 2)
{
table.rows[c].cells[0].style.display = "none";
table.rows[c].cells[1].style.display = "none";
}
}
}
}
}
}
$( "#WPQ2_nav_prev_a" ).click(function() {
month();
})
$( ".ms-picker-table" ).click(function() {
month();
})
$( "#WPQ2_nav_next_a" ).click(function() {
month();
})
setInterval(function () { month()}, -10000);
setInterval(function () { month()}, -10000);
setInterval(function () { week()}, -10000);
</script>
This is similar to the prior answer but it hides the 6th and 7th day of the Week View with CSS, instead of JavaScript. This snippet works with the Week View on the calendar webpart. There are other class names on the Month View but it follows the same pattern.
You will also need to set the regional settings on the Site Collection to make the Week Start at Monday, not Sunday, for this code to work. It assumes that Saturday and Sunday are the 6th and 7th days in the week.
/* Week View, hide Saturday and Sunday */
.ms-acal-detail tbody tr td:nth-child(7), .ms-acal-detail tbody tr td:nth-child(8) {
display:none;
}
Hope this helps.