Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
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. –  Andrey Markeev Jan 11 '12 at 16:23
    
I've added 2 screenshots to clarify my problem :). The tab is not showing at all. –  Marlou Jan 12 '12 at 8:57
    
Thanks, got it now. –  Andrey Markeev Jan 12 '12 at 9:35

2 Answers 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.

share|improve this answer
    
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 '12 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. –  Andrey Markeev Jan 13 '12 at 11:00
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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