How to hide the sharepoint list ribbon features from item display page

Answered How to hide the sharepoint list ribbon features from item display page

  • שבת 12 מאי 2012 12:35
     
     

    Hi,

    I have created List with named  ' Testimonials '

    i am able hide the ribbon features in Lists/Testimonials/AllItems.aspx  path. using with below code.

    SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

    ribbon.TrimById("Ribbon.ListItem.New.NewListItem"); //hide new button

     ribbon.TrimById("Ribbon.ListItem.Manage");

    but in list items i have link with Title, so when user click on that link list view is getting to open.

    so now i want to hide the ribbon items from view page also

    can we  do this with custom coding only ? if so how ?

    or can we hide or remove complete ribbon from that particular list Display page ?


    MD.Liakath ali


    • נערך על-ידי Liakath שבת 12 מאי 2012 12:38
    •  

כל התגובות

  • שבת 12 מאי 2012 14:22
     
     תשובה קוד כלול

    In order to completely hide ribbon either add ContentEditor webpart on your page ( or change the standard one with SharePoint Designer):

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <!-- если эта библиотека уже не подключена на мастер странице или в additionalpagehead -->
    <script type="text/javascript">
                function HideRibbon() {
                    $('#s4-ribbonrow').hide();
                    var newHeight = $(document).height();
                    if ($.browser.msie) { newHeight = newHeight - 3; }
                    $('#s4-workspace').height(newHeight);
                }
    </script>

    and in order to completely hide ribbon just call HideRibbon() function.


    Or... add the following style to page:

        <script type="text/javascript">
            document.getElementById("s4-ribbonrow").style.display = "none";
        </script>
    Or... customize that form with InfoPath and disable ribbon via InfoPath form settings.


    LinkedIn Profile


  • יום שלישי 15 מאי 2012 18:37
     
     

    You can also hide the ribbon using Sharepoint:SPSecurityTrimmedControl.

    <Sharepoint:SPSecurityTrimmedControl runat="server"

    Permissions="AddAndCustomizePages">
    <style type="text/css">
    div#s4-ribbonrow {
    display:block;
    }
    </style>
    </Sharepoint:SPSecurityTrimmedControl>


  • שבת 30 יוני 2012 06:05
     
     

    hi,

    I tried to call the HideRibbon() function when $(document).ready. I'm able to hide the ribbon when first open the edit form. But after I click the Attach File function, either I upload a file, click OK button or I just cancel and back to the edit form, the ribbon come back to the edit form. Where should I call the HideFunction? Need help urgently. Thanks.

  • שבת 30 יוני 2012 07:00
     
      קוד כלול

    Hi,

    If you want to hide the ribbon completely then add the below script into particular page using with Content editor webpart. like editform.aspx, dispitem.aspx

    <script type="text/javascript">
            document.getElementById("s4-ribbonrow").style.display = "none";
        </script>


    MD.Liakath ali


    • נערך על-ידי Liakath שבת 30 יוני 2012 07:11
    •