I have a custom list definition that I’ve been writing. The ribbon on it looks something like this:
Unfortunately, I don’t want some of the groups shown on this tab. For example, I don’t want any of the ‘Connect & Export’ group, or ‘Customize List’ – these things could actually break my solution. So, how to hide?
Initially, I looked at the HideCustomAction Feature element. This what you’d use for hiding links to settings pages, etc., and it seems a natural choice. Unfortunately, it doesn’t allow a RegistrationId in the same way that a CustomAction element does – so there was no way to restrict this to my list only. Damn.
I was beginning to consider simply replacing the buttons with ones that would never be enabled – something like outlined here (near the bottom “Replacing a Button”. I began to wonder could I just specify an empty button, and then I found a very useful article that mentions simply specifying an empty Tab Group. Fantastic!
So, I tried it:
<CustomAction Id="RemoveConnectAndExportGroup" Location="CommandUI.Ribbon.ListView" RegistrationId="9999" RegistrationType="List"> <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location="Ribbon.List.Actions" /> <!-- DELIBERATELY EMPTY --> </CommandUIDefinitions> </CommandUIExtension> </CustomAction>
And this hid my tab nicely! The following screenshot shows a few tabs being hidden:
Also, it turns out the same approach works on individual buttons.