4

I wish to edit my 2013 Calendar web part and remove Saturday and Sunday from showing if possible so it only shows the work days of the week. Any help would be very much appreciated as i dont know where to start with it,

Cheers.

3
  • using some jquery function you can hide it. Nov 22, 2013 at 9:13
  • Can you elaborate...? :)
    – Shwabster
    Nov 22, 2013 at 9:25
  • you can create one jquery inside this page. for jquery reference [click here] (jsfiddle.net/d6JWV/1) Nov 22, 2013 at 9:45

2 Answers 2

2

Maybe old, but I found a way which works for me.

Source: http://www.c-sharpcorner.com/UploadFile/fc34aa/hide-weekends-in-sharepoint-calendar-view/

Code:

<style type="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> 

I just followed the steps provided in the link which are mostly:

  1. Added a Content Editor to the page
  2. Added the code above
  3. Saved everything
  4. Done
2
  • this works perfectly with the Monthly View , do you know how to convert this to also work with weekly view ?!
    – Bucki
    Jan 6, 2017 at 13:22
  • This only works in the calendar itself, not when you add calendar as web part to another page, anyone have a suggestion for that? Feb 24, 2017 at 18:05
-1

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>

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