SharePoint 2010 – Hide Ribbon buttons Programatically


SharePoint 2010 – Hide Ribbon buttons Programatically

Hide Ribbon(whole Ribbon) SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

if (ribbon != null) { ribbon.TrimById(“RibbonGroupId”); }

What is this RibbonGroupId ?

Well the idea is to hide all the groups in the ribbon and the whole ribbon will be trimmed. To get the id’s for ribbon groups, Open the file C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML in Internet Explorer and search for “Ribbon.EditingTools.CPEditTab.Groups

The sub-nodes are the ones you’re interested in – a collection of GROUP nodes. The groups should look familiar – they correlate to the panes on the ribbon pane :

Ribbon.EditingTools.CPEditTab.EditAndCheckout

Ribbon.EditingTools.CPEditTab.Clipboard

Ribbon.EditingTools.CPEditTab.Font Ribbon.EditingTools.CPEditTab.Paragraph

Ribbon.EditingTools.CPEditTab.Styles  Ribbon.EditingTools.CPEditTab.Layout

Ribbon.EditingTools.CPEditTab.Markup

so to trim the while ribbon just use the ribbon groups like below for e.g . ribbon.TrimById(“Ribbon.EditingTools.CPEditTab.EditAndCheckout”);

Side Note : You can add this code in a custom web user control and the control to the master page.

Hide a single Button on Ribbon

Copied from our Forum Post Here the goes goes as below :

public void HideRibbonButton()

{ //if this is a System.Web.UI.Page

SPRibbon ribbon = SPRibbon.GetCurrent(this); ribbon.TrimById(“Ribbon.DocLibListForm.Edit.Actions.DeleteItem”);

}

Hide group

As seen in the first scenario you can use groupid to hide the ribbon groups like below ribbon.TrimById(“Ribbon.EditingTools.CPEditTab.EditAndCheckout”);

Advertisements

About sharepointsriram

9+ Yrs of IT experience
This entry was posted in Sharepoint 2010 Ribbon. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s