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.

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
  • this works perfectly with the Monthly View , do you know how to convert this to also work with weekly view ?! – Bucki Jan 6 '17 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? – dylan murphy Feb 24 '17 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>

protected by Community Mar 4 '16 at 19:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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