none
Hide Upload Document item in Ribbon

    Dotaz

  • I created a document library set to use a "Document Set" content type.  I am hiding the "Document" content type, so that when a user clicks "New Document", in the Ribbon, they are only able to create a Document Set.  Is there a way to hide "Upload Document" item in them Ribbon at this level?  Meaning, once the Document Set is created the user should be allowed to "upload" documents into the Document Set?  I want to prevent them from uploading documents at the document set creation level.
    14. června 2012 17:06

Odpovědi

Všechny reakce

  • OR best way try this ... Let me know if this helps..

    Best way is you can disable the option within the document library.
    
    1. Edit the document library page and Add a content editor webpart in your document library
    
    2. Paste below script in source code of CEWP
    
    <script type="text/javascript">
    function GetElementByText(tagName, title)
    {
    var a = document.getElementsByTagName(tagName);
    
    for (var i=0; i < a.length; i++)
    {
    if (a[i].text)
    {
    if (a[i].text === title)
    {
    return a[i];
    }
    }
    }
    
    return null;
    }
    
    if (window.onload)
    {
    var oLoad = window.onload;
    window.onload = function bodyLoad()
    {
    oLoad();
    
    var o = GetElementByText("ie:menuitem","Upload Document");
    var k = GetElementByText("ie:menuitem","Upload Multiple Documents");
    if (o || k)
    {
    o.disabled = true;
    k.disabled = true;
    }
    }
    }
    </script>

    14. června 2012 17:59
  • Thanks - but this hides the Library Tools tab, so I am not able to get to the Documents or Library sections in the Ribbon.
    15. června 2012 14:00
  • Hi,

    You can use TrimById funcion by Object model.

    I suggest you create a webpart and overrides OnPreRender by putting this code:

    ...
    Dim ribbon As Microsoft.SharePoint.WebControls.SPRibbon = SPRibbon.GetCurrent(Me.Page)
    
    ribbon.TrimById("Ribbon.Documents.New.AddDocument")
    ...

    All controls ids: http://msdn.microsoft.com/en-us/library/ee537543(en-us,office.14).aspx

    Remember that you MUST paste this code at OnPreRender not in CreateChildControls method.

    Regards!



    José Quinto Zamora
    SharePoint and Search Specialist at SolidQ(http://www.solidq.com)
    MCITP and MCPD in SharePoint 2010
    http://blogs.solidq.com/sharepoint

    15. června 2012 14:19
  • TrimById must be used in a Farm Solution, correct?  Unfortunately, this is SharePoint Online and must be a Sandboxed Solution.  Additionally, I need the Upload Document button to be disabled or hidden only when creating Document Sets in the doc library.  Within the Document Set - I do want the user to be able to upload documents.  Given this requirement is jquery/css route my only option?
    15. června 2012 14:42
  • Hi,

    You could try to create a webpart with this code in a sandbox solution.

    Maybe you need to put this webpart only in pages that you are interested in.

    You can see limitations on sandbox: http://msdn.microsoft.com/en-us/library/gg615454.aspx#BKMK_BlockClasses

    And What Can Be Implemented in SandBox: http://msdn.microsoft.com/en-us/library/gg615464.aspx

    Regards!



    José Quinto Zamora
    SharePoint and Search Specialist at SolidQ(http://www.solidq.com)
    MCITP and MCPD in SharePoint 2010
    http://blogs.solidq.com/sharepoint

    15. června 2012 14:57
  • You can also hide the items in the Ribbon with CSS:

    <style type="text/css">
    #Ribbon\.Documents\.New 
    {
    display: none !important;
    }
    </style>


    /blog twttr @esjord

    • Označen jako odpověď obautista 15. června 2012 17:11
    15. června 2012 15:10
  • Hi,

    You can create a sandbox solution with the following feature\elements.xml to remove Upload document in the Ribbon. If you need this active for only one library you can either create a new Content type from document and then specify the Id in RegistrationId or you will have to create a new list template for you document library and specify the id of list template in RegistrationId.

    <CustomAction
        Id="RemoveExplorerButton"
        Location="CommandUI.Ribbon"
        RegistrationType="List"
        RegistrationId="{contentTypeId}">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Library.Documents.upload" />  -> verify this
          </CommandUIDefinitions>
        </CommandUIExtension>
      </CustomAction>

    15. června 2012 15:34
  • This did the trick.  It hid the Upload button and am hiding the Add New with the Main web part zone:

    <style type="text/css"> 
    #Ribbon\.Documents\.New\.AddDocument-Large
    {     
    	display:none !important; 
    } 
    </style>
    <style type="text/css"> 
    td.ms-addnew
    {     
    	display:none !important; 
    } 
    </style>

    15. června 2012 17:10
  • I had the same issue as you and this worked for me.  Thank you. 

    C# Developer

    28. ledna 2014 21:05