Question

wighttrash on Wed, 28 Dec 2011 23:36:58


I need to create a simple feature and deploy as a sand boxed solution that hides buttons on the ribbon that user do not want to see.  

For example, i want to remove the new folder, version history, manage permissions, attach file, workflows, and tags buttons.  

 

I followed a tutorial from MSDN but could not get my code to work.  Here is my elements.xml file which is supposed to hide the manage permissions and view versions:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
    Id="RemoveRibbonButton"
    Location="CommandUI.Ribbon">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.ListItem.Manage.ViewVersions"/>
                <CommandUIDefinition Location="Ribbon.ListItem.Manage.ManagePermissions"/>
            </CommandUIDefinitions>
        </CommandUIExtension>
    </CustomAction>
</Elements>

When i followed the tutorial to hide the connect to outlook button everything worked fine.

 

Any Ideas? 

 

 

 


Sponsored



Replies

Ram Prasad Meenavalli on Thu, 29 Dec 2011 04:10:41


Hello,

Use this in your elements.xml file and try

 

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
  Id="RemoveRibbonButton"
  Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListItem.Actions.AttachFile"/>
        <CommandUIDefinition Location="Ribbon.ListItem.New.NewFolder"/>
        <CommandUIDefinition Location="Ribbon.ListItem.Manage.ViewVersions"/>
        <CommandUIDefinition Location="Ribbon.ListItem.Manage.ManagePermissions"/>
        <CommandUIDefinition Location="Ribbon.ListItem.Workflow.ViewWorkflows"/>
        
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>
</Elements>

On activating the feature, I am able to hide "Attach File", "New Folder", "Version History", "Item Permissions" and "Workflows" buttons in my List.....

 


Ram Prasad Meenavalli | MCTS SharePoint 2010 | MCPD SharePoint 2010

Shantha Kumar T on Thu, 29 Dec 2011 04:54:55


If you want to hide the ViewPermissions and ManagePermissions, you have to specify the RegistrionId and RegistrationType.

Specify Template Id in Registrartion Id and specify Type of the Template in RegistrationType.

Suppose If you want to hide the buttons in Generic List, you have to add the followng xml snippet in element file.

 <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
  Id="RemoveRibbonButton"
  RegistrationId="100"
  RegistrationType="List"
  Location="CommandUI.Ribbon">
  <CommandUIExtension>
    <CommandUIDefinitions>
      <CommandUIDefinition Location="Ribbon.ListItem.Manage.ViewVersions"/>     
      <CommandUIDefinition Location="Ribbon.ListItem.Manage.ManagePermissions"/>
    </CommandUIDefinitions>
  </CommandUIExtension>
  </CustomAction>
</Elements>

 


Regards,
Shantha Kumar .T | MCPD - SharePoint Developer 2010 | MCITP - SharePoint Administrator 2010
(B) Shantha Kumar's Blog | (T)Follow me

wighttrash on Thu, 29 Dec 2011 16:41:20


Thanks you so much! That worked great.  I am new to SharePoint Development and never saw anything about the RegistrationId or RegistrationType.  Is there someplace i can go to learn more about them to avoid this issue in the future?  Thanks again for your help.  

wighttrash on Thu, 29 Dec 2011 17:23:32


One more question.  The solution works great when viewing the list but when you add the list to a web part page the buttons show up again.  What do i need to do to remove the buttons when the list is being viewed on a web part page.  Thanks again for the help.  

Qiao Wei on Fri, 30 Dec 2011 10:05:34


Hi wighttrash,

To hide the list actions on the web part page, here is an article about this, please refer to it for more information:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/0008aa6d-a56e-4928-87c3-c075fbc28cca

Thanks,
Qiao

wighttrash on Fri, 30 Dec 2011 17:23:32


The link points to this thread and not an article, unless you are playing a joke on me:).  

Qiao Wei on Sat, 31 Dec 2011 05:46:13


Hi wighttrash,

I’m really sorry for my mistake, please refer to the following link, it shows an example about how to hide ribbon on list view web part, you can have a check whether it will meet your requirement:
http://stackoverflow.com/questions/3561304/how-to-hide-the-list-ribbon-in-xslt-list-web-part-in-sharepoint-2010

Thanks,
Qiao

wighttrash on Tue, 03 Jan 2012 16:07:28


That article is great and it works just fine in dev but i can't deploy a farm solution in our environment.  I need it to be a sandboxed solution and according to MSDN the SPRibbon class is not available in sandboxed solutions.  Any other suggestions?  

Sjoerd Schudde on Wed, 14 Nov 2012 12:35:16


it is possible to hide Ribbon-items in CSS:

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

jd_hancock on Tue, 19 Feb 2013 13:16:51


This works great Sjoerd.  Thanks for the input.  Do you know how this can be applied using Javascript or Jquery?  I want to dynamically hide the button depeneding on some other criteria.  Tried using the following but page throws Object is null or undefined error.

document.getElementById('Ribbon.ListItem.New.NewListItem-Large').style.display='none';

and

$("#Ribbon.ListItem.New.NewListItem-Large").hide();
It appears as though the ID is removed from the tag after the page is loaded.  View source does not show the id at all.  Only IE developer shows it.  Firefox doesn't show it in "Inspect Element" or view page source.  Only IE has access to the id.  Must be proprietary MS stuff that only MS software can access.


Sjoerd Schudde on Sat, 23 Feb 2013 21:47:55


I 'am not sure why it not works.

Can you try this example to hide and show the complete Ribbon.

You can add the code in an Content Editor Web Part.

<script type="text/javascript">
function ShowRibbonRow() 
{$("#s4-ribbonrow").show(); }
function HideRibbonRow() 
{ $("#s4-ribbonrow").hide(); }
_spBodyOnLoadFunctionNames.push("HideRibbonRow");
</script>
<div class="w-Ribbon">
<a href="#" onclick="Javascript:ShowRibbonRow();">Show</a>
<a href="#" onclick="Javascript:HideRibbonRow();">Hide</a>
</div>

jd_hancock on Mon, 25 Feb 2013 17:46:41


I can show the ribbon or hide the ribbon.  That works most of the time.  Sometimes the page has to be refreshed before this will work.  Unreliable but works sometimes.