locked
hiding the 'Edit Series' button in Reoccuring Event in DispForm,aspx using javascript RRS feed

  • Question

  • All,

    I am attempting to hide the menu item "Edit Series" when users view a reoccuring event in the dispform.aspx.  I have figured out a clean way of hiding fields due to Cleverworkarounds.com, but I have not been successful at hiding the menu item controls.  I found the below code and attempted to edit it to my needs, but unfortunately no success.  Any suggestions.  This was originally setup to hide the new item button and alert me button.  It still successfully removes the alert me due to the else statement, but doesn't touch the Edit Series button.  So I know the placement of the CEWP is correct.

    <SCRIPT language=javascript>
    hideFormMenuItems("Edit Series");
            function hideFormMenuItems() {
                var titleToHide = "";
                var anchorTag;
                var allAnchorTags = document.getElementsByTagName('a');
                for (var i = 0; i < hideFormMenuItems.arguments.length; i++) {
                    titleToHide = hideFormMenuItems.arguments[i];
                    if (titleToHide != 'Edit Series') {
                        for (var j = 0; j < allAnchorTags.length; j++) {
                            anchorTag = allAnchorTags[j];
                            if (anchorTag.title.indexOf(titleToHide) != -1) {
                                anchorTag.parentNode.parentNode.parentNode.parentNode.
    parentNode.style.display = "none";
                                anchorTag.parentNode.parentNode.parentNode.parentNode.
    parentNode.nextSibling.style.display = "none";
                                break;
                            }
                        }
                    }
                    else {
                        for (var k = 0; k < allAnchorTags.length; k++) {
                            anchorTag = allAnchorTags[k];
                            if (anchorTag.id.indexOf("SubscribeButton") != -1) {
                                anchorTag.parentNode.parentNode.parentNode.parentNode.
    parentNode.style.display = "none";
                                break;
                            }
                       }
     
                     }
                }
                var allSpanTags = document.getElementsByTagName("span");
                var spanTag;
                var toolbarRow;
                var lastCell;
                for (var m = 0; m < allSpanTags.length; m++) {
                    spanTag = allSpanTags[m];
     
                    if (spanTag.id == 'part1') {
                        toolbarRow = spanTag.childNodes[2].firstChild.firstChild;
                        lastCell = toolbarRow.lastChild.previousSibling
                        while (lastCell.style.display == 'none') {
                            lastCell = lastCell.previousSibling;
                        }
                        if (lastCell.innerText == '|') {
                            lastCell.style.display = 'none';
                        }
                        break;
                    }
                }
            }
    </SCRIPT>

    Thursday, February 9, 2012 11:58 PM

Answers

  • ended up adding jquery in the 1 WFE in our farm to following path so it would be available in every CEWP I add, C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS.

    I then added this script to the CEWP, exported the web part and added it to the default web part gallery so I could reuse it as needed.

    <script type="text/javascript" src="<a href="http:///_layouts/jquery-1.7.1.min.js"></script">http://<SHAREPOINTSERVERNAME>/_layouts/jquery-1.7.1.min.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {

      $("td.ms-titlearea").hide();
      $("a[title='Edit Series']").parent().parent().parent().hide();
      $("td.ms-seperator:nth-child(3)").hide();

    });
    </script>

     

    • Marked as answer by STNY12 Thursday, February 23, 2012 3:34 PM
    Thursday, February 23, 2012 3:34 PM

All replies

  • I may just look into a JQuery solution, as it seems a bit less complicated.  Thanks to all viewers.

    Monday, February 13, 2012 9:13 PM
  • ended up adding jquery in the 1 WFE in our farm to following path so it would be available in every CEWP I add, C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS.

    I then added this script to the CEWP, exported the web part and added it to the default web part gallery so I could reuse it as needed.

    <script type="text/javascript" src="<a href="http:///_layouts/jquery-1.7.1.min.js"></script">http://<SHAREPOINTSERVERNAME>/_layouts/jquery-1.7.1.min.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {

      $("td.ms-titlearea").hide();
      $("a[title='Edit Series']").parent().parent().parent().hide();
      $("td.ms-seperator:nth-child(3)").hide();

    });
    </script>

     

    • Marked as answer by STNY12 Thursday, February 23, 2012 3:34 PM
    Thursday, February 23, 2012 3:34 PM