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 would like to add a button into the Web Part Tools ribbon section.

enter image description here

I have looked in CMDUI.XML to find the other buttons which are in this section and it appears they should be under Ribbon.WebPartOption. and i have tried a bunch of different paths under this but havent managed to get a button to show up. Below is my current code:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Id="AddAsDashboardItem"
        Location="CommandUI.Ribbon"
        Sequence="5">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Properties.Controls._children">
                    <Button
                        Id="Ribbon.WebPartOption.Commands.AddAsDashboardItemButton"
                        Command="AddAsDashboardItem_Button"
                        Sequence="5"
                        Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
                        Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
                        LabelText="Add As Dashboard Item"
                        TemplateAlias="o1" />
                </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
                <CommandUIHandler
                  Command="AddAsDashboardItem_Button"
                  CommandAction="javascript:alert('SharePoint ribbon button');" />
            </CommandUIHandlers>
        </CommandUIExtension>
    </CustomAction>
</Elements>

Does anyone know what location i need to put a button in this section of the ribbon?

EDIT

I tried to add it into my own group and I got the following:

enter image description here

There's a group there but no button. My code below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Id="Ribbon.WebPartOption.Dashboard"
        Location="CommandUI.Ribbon"
        Sequence="5">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Groups._children">
                    <Group
                        Id="Ribbon.WebPartOption.Dashboard.Group"
                        Sequence="70"
                        Title="Dashboards"
                        Template="Ribbon.Templates.ManageViewsGroup">
                        <Controls Id="Ribbon.WebPartOption.Dashboard.Group.Controls">
                            <Button
                                Id="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Button"
                                Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
                                Sequence="1"
                                Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
                                Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
                                LabelText="Add As Dashboard Item"
                                TemplateAlias="o1" />
                        </Controls>
                    </Group>
                </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
                <CommandUIHandler
                  Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
                  CommandAction="javascript:alert('SharePoint ribbon button');" />
            </CommandUIHandlers>
        </CommandUIExtension>
    </CustomAction>
</Elements>

EDIT2:

It ended up that I also needed to define scaling options. Below is a working example:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Id="Ribbon.WebPartOption.Dashboard"
        Location="CommandUI.Ribbon"
        Sequence="5">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Groups._children">
                    <Group
                        Id="Ribbon.WebPartOption.Dashboard.Group"
                        Sequence="70"
                        Title="Dashboards"
                        Template="Ribbon.Templates.Flexible2">
                        <Controls Id="Ribbon.WebPartOption.Dashboard.Group.Controls">
                            <Button
                                Id="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Button"
                                Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
                                Sequence="1"
                                Image16by16="/_layouts/images/Dashboard2010/AddDashboardItem_16x16.bmp"
                                Image32by32="/_layouts/images/Dashboard2010/AddDashboardItem_32x32.bmp"
                                LabelText="Add As Dashboard Item"
                                TemplateAlias="o1" />
                        </Controls>
                    </Group>
                </CommandUIDefinition>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
                    <MaxSize Id="Ribbon.WebPartOption.Dashboard.MaxSize"
                             GroupId="Ribbon.WebPartOption.Dashboard.Group"
                             Sequence="20"
                             Size="LargeLarge"/>
                </CommandUIDefinition>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
                    <MaxSize Id="Ribbon.WebPartOption.Dashboard.MediumMedium"
                             GroupId="Ribbon.WebPartOption.Dashboard.Group"
                             Sequence="30"
                             Size="MediumMedium"/>
                </CommandUIDefinition>
                <CommandUIDefinition Location="Ribbon.WebPartOption.Scaling._children">
                    <MaxSize Id="Ribbon.WebPartOption.Dashboard.Popup"
                             GroupId="Ribbon.WebPartOption.Dashboard.Group"
                             Sequence="20"
                             Size="Popup"/>
                </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
                <CommandUIHandler
                  Command="Ribbon.WebPartOption.Dashboard.AddAsDashboardItemButton.Command"
                  CommandAction="javascript:alert(getId());" />
            </CommandUIHandlers>
        </CommandUIExtension>
    </CustomAction>
</Elements>
share|improve this question
    
If you don't end up with a declarative way of approaching this you could also add this using the Ribbon Javascript library as needed. –  Alex Taylor Apr 3 '13 at 5:47
add comment

1 Answer

up vote 1 down vote accepted

I think that the main problem is in registration id and type.

RegistrationId="101"
RegistrationType="List"

You tells SharePoint to insert you action to the ribbon of a list that is a document library. See this post to understand how to add action into existing tab.

share|improve this answer
    
Thanks, your right these dont belong here, i removed them and simplified my example to match more closely to the COB one but i still cant get it to go. I think the location string is still wrong. Any idea where i can go to find out the correct location string? –  Luke McGregor Apr 3 '13 at 8:45
1  
Can you use this example? All examples that I found contains definition for a custom group. Is it ok for you? –  Alexander Apr 3 '13 at 9:01
    
I gave that a go and the group shows up but not the button. I guess that means its probably something other than the location. I cant see any other differences between my code and the COB or the example you referenced. Im pretty sure the actual button code is OK as i tried it earier on a regular list ribbon and it worked fine. –  Luke McGregor Apr 3 '13 at 9:29
1  
I do not see any reason. Only difference is a image extension. You use bmp, in the example it is a png. Also there are scaling options. –  Alexander Apr 3 '13 at 10:21
add comment

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.