Thursday, 17 November 2011

Hiding Ribbon Group for a specific list\library Programmatically in SharePoint 2010


Here are my thoughts on hidding or removing a Ribbon group from a specific list\library.

To remove a group you can simply add a fetaure in your sharepoint 2010 site which will have an empty definination for that group location. This will override the existing group display functionality.
To make this feature specific to a list\library simple create a List template and then assign the List template id to the feature that you created above.

Steps -

1. Create a List Definition or List template using Feature -
See the below article from msdn to create a List templete using feature.
Msdn Article - http://msdn.microsoft.com/en-us/library/ms466023%28v=office.12%29.aspx

2. Create a list\library using the new template.

3. Create a new Custom action Feature in Visual studio with a Location as of the existing Group that you want to hide.

The below goes in your elements.xml
<customaction

Id="Removing.ExistingGroup"

Regestration id = "{Id of List Template}";

Location="CommandUI.Ribbon">

<commanduiextension>

<commanduidefinitions>

<commanduidefinition Location="Ribbon.WikiPageTab.Groups._children">

<group Id="<b>Id of Group you want to Remove</b>" />

</CommandUIDefinition>

</CommandUIDefinitions>

</CommandUIExtension>

</CustomAction>

4. Next use the feature id of the above created List Definition (created in step#1) as registration id of the custom action (created in step#3).

Alternatively, you can also create a content type in Step 1 and use the content type id in Step 4 However, in this case you need to use
this content type in your list\library and the Group will only be unavailable for only this Content type.

5. Deploy the solution in your SharePoint site and activate the Feature.

Result - The Group that you specified should be removed from the List you created in Step#2.

Ads by Google

No comments:

Post a Comment