2

I've created a custom ribbon tab that shows for a specific contenttype like this:

  <CustomAction
   Id="IncomingDocumentTab"
   Location="CommandUI.Ribbon"
   RegistrationId="0x010100476E04EA2BFC4CADA2420D300CF1433B"
   RegistrationType="ContentType">

The tab works fine on my library. When I add a webpart with this list to my page, the tab is not showing.

This image shows the tab in the list: enter image description here

Then if i create a default lists and libraries webpart of the same list, like this way (sorry that the site is in dutch)

enter image description here

if I have added this webpart, the tab isn't showing.

Is it possible to show the tab when you select a document in the webpart?

In reaction of Omlin's post, I've tried to change Ribbon.Tabs._children to Ribbon.LibraryContextualGroup._children. this works for the library itself, but not for the webpart.

enter image description here enter image description here

2
  • 1
    I'm a bit confused by your two last sentences :) Do you mean that the tab is shown but not active or what? And which webpart exactly are you adding? Please, consider rephrasing or illustrating your question with a screenshot. Jan 11, 2012 at 16:23
  • I've added 2 screenshots to clarify my problem :). The tab is not showing at all.
    – Marlou
    Jan 12, 2012 at 8:57

2 Answers 2

2

The problem is that you have static tab. Unfortunately, in this case you'll need to perform some additional actions on the page where you're adding the library webpart.

More specifically, you'll need to call MakeTabAvailable method, passing tab id as a parameter (and optionally, id of visibility context of the webpart). Since the document library webpart could be added on any site page, most obvious option here will be to use Delegate Control technique.

However, dealing with Delegate Controls is a dangerous habit, and I'd avoid it unless it's absolutely neccessary.

Thus, I'd recommend you to consider another approach, when your tab will appear inside "Library Tools" contextual group rather than separately.

I mean, now you have this:

enter image description here

and I suggest to move your "PRO/Staal" tab into "Hulpmiddelen voor bibliotheken" contextual tab group, placing it next to "Documenten" and "Bibliotheek" tabs.

This approach will allow you to avoid using Delegate Controls.

Only custom action will be required. The only thing you have to change in your current solution, is Location attibute value of the CommandUIDefinition element.

Now you have this code:

<CommandUIDefinition Location="Ribbon.Tabs._children">
    <!-- tab definition goes here -->
</CommandUIDefinition>

And you will have to change "Ribbon.Tabs._children" to "Ribbon.LibraryContextualGroup._children":

<CommandUIDefinition Location="Ribbon.LibraryContextualGroup._children">
    <!-- tab definition goes here -->
</CommandUIDefinition>

P.S. If you're dealing with SharePoint ribbon often, I'd recommend you to probe Fluent Ribbon API opensource project. It simplifies work with ribbon enormously, and for example at my company this library is an unofficial standard, and we use it extensively for our enterprise product.

For your particular case, Fluent Ribbon API offers RibbonCustomAction feature and convenient AddTabToContextualGroup method.

2
  • I've changed the location to Ribbon.LibraryContextualGroup._children, but the tab is still not showing with the webpart. Am I missing anything else? I'm definitely going to check the FLuent Ribbon API, thanks for the tip!
    – Marlou
    Jan 13, 2012 at 10:35
  • Hmm, that's strange. Have you cleared the browser cache? Actually I've tested this approach with the only difference, that custom action was attached directly to list, rather than to a content type (but I don't think this makes any sense). And it worked perfectly. Jan 13, 2012 at 11:00
0

I've finally found what I was missing. In the webpart settings, the toolbar type setting was "Summary toolbar". After I've changed it to "Full Toolbar" my tab showed up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.