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
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 :
o Ribbon.EditingTools.CPEditTab.EditAndCheckout
o Ribbon.EditingTools.CPEditTab.Clipboard
o Ribbon.EditingTools.CPEditTab.Font
o Ribbon.EditingTools.CPEditTab.Paragraph
o Ribbon.EditingTools.CPEditTab.Styles
o Ribbon.EditingTools.CPEditTab.Layout
o Ribbon.EditingTools.CPEditTab.Markup
o Ribbon.EditingTools.CPEditTab.Clipboard
o Ribbon.EditingTools.CPEditTab.Font
o Ribbon.EditingTools.CPEditTab.Paragraph
o Ribbon.EditingTools.CPEditTab.Styles
o Ribbon.EditingTools.CPEditTab.Layout
o 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”);
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”);
}
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”);
Comments
Post a Comment