3

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.

  • I was personally never able to implement this correctly, and I think the reason for it was something to do with things I had edited in the Master Pages. However, OOTB, I do not believe there are any solutions. You can accomplish this using JQuery, though, because I never got it to work I am not entirely sure how. Hope that points you in the right directions. Also, the following link may help. sharepointkings.com/2008/08/create-custom-listviewwebpart.html – Zach Little Jul 6 '12 at 17:53
1

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

0

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>
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.