Problems with customizing Ribbon for webparts with “Summary Toolbar”
-
16-10-2019 - |
Question
I have a problem with customizing Ribbon for webparts with "Summary Toolbar". I add the button through CAML code. (Generated by SPSF, but shouldn't matter)
My buttons shows up when viewing the list directly, or in webparts with "Full toolbar".
I have tried to registered my buttons to both content types and list definitions, but it still has the same behaviour.
I found a couple of blog posts with other people struggeling with the same problem, this one describes it well with screenshots: http://www.itidea.nl/index.php/custom-ribbon-button-doesnt-show-up/
Has anyone managed customizing the ribbon with summary toolbar? Is this the intended behaviour?
<?xml version="1.0" encoding="utf-8"?>
<!-- Code initially generated with SharePoint Software Factory 2010, Version 3.1, spsf.codeplex.com -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Ribbon.EDBErgoGroup.ASC2011.RibbonSampleContentTypeButton1"
Location="CommandUI.Ribbon"
Title="RibbonSampleContentTypeButton1"
RegistrationType="ContentType"
RegistrationId="0x0101">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.New.Controls._children">
<Button
Id="Ribbon.EDBErgoGroup.ASC2011.RibbonSampleContentTypeButton1.Button"
Command="EDBErgoGroup.ASC2011.RibbonSampleContentTypeButton1.ButtonCommand"
Sequence="500"
Image16by16="/_layouts/images/EDBErgoGroup_ASC2011/RibbonIcon_RibbonSampleContentTypeButton1_16.gif"
Image32by32="/_layouts/images/EDBErgoGroup_ASC2011/RibbonIcon_RibbonSampleContentTypeButton1_32.gif"
LabelText="RibbonSampleContentTypeButton1"
ToolTipTitle="RibbonSampleContentTypeButton1"
ToolTipDescription="Description of RibbonSampleContentTypeButton1"
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="EDBErgoGroup.ASC2011.RibbonSampleContentTypeButton1.ButtonCommand"
CommandAction="javascript:alert('Hello, world');" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
Solution
The view's ToolbarType must internally be "Freeform" (which seems to equate to "Full toolbar"). Otherwise, if the ToolbarType is either "Standard" (summary) or "ShowToolbar" (the v3 type), the view's custom toolbar won't render.
A delegate control or custom page component could bootstrap customizations using reflection + the instance returned by SPRibbon.GetCurrent(), or possibly initialize and add the DataFormWebPart's ToolbarControl -- but this would really just be a very awkward way of switching the view's toolbar type. Automating the latter would be a lot easier.