none
Move sharepoint default ribbon buttons from one group to other

    Question

  • Hi,

    Is there any way to change the default sharepoint ribbon button's placing? I know how to add new buttons in existing groups as well in new groups on the ribbon but not sure how to change the default buttons placing. For instance I have a specific custom group called 'Print Items' and within this group there are two custom buttons for different functionalities. I need to move some of the default buttons i.e. send email/export to excel/print buttons in to the custom group. Please suggest me how to do this. Thanks in advance.

    Thursday, December 1, 2011 4:53 AM

Answers

  • Hi Surya,

    The default ribbon groups and buttons are defined in CMDUI.xml file in the location of: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML, you can locate to it and have a check.

    To add existing button to a new group, you can copy the button in the CMDUI.xml file, then paste it to the new group definition file and render section for it, hidden the existing button.

    For example, I have a custom group for Shared Document library like this:
    <Groups Id="Ribbon.CustomTabExample.Groups">

                  <Group

                    Id="Ribbon.CustomTabExample.CustomGroupExample"

                    Description="This is a custom group!"

                    Title="Custom Group"

                    Sequence="52"

                    Template="Ribbon.Templates.CustomTemplateExample">

                    <Controls Id="Ribbon.CustomTabExample.CustomGroupExample.Controls">

                      <Button

                        Id="Ribbon.CustomTabExample.CustomGroupExample.HelloWorld"

                        Command="CustomTabExample.HelloWorldCommand"

                        Sequence="15"

                        Description="Says Hello to the World!"

                        LabelText="Hello, World!"

                        TemplateAlias="cust1"/>

                    </Controls>

                  </Group>

                </Groups>

    Then copy the existing button and paste it to the Groups tag, for example view properties button:
    <Button

                    Id="Ribbon.Documents.Manage.ViewProperties"

                    Sequence="10"

                    Command="ViewProperties"

                    Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-32" Image16by16Left="-80"

                    Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-96" Image32by32Left="-448"

                    LabelText="$Resources:core,ButViewProperties;"

                    ToolTipTitle="$Resources:core,ButViewProperties;"

                    ToolTipDescription="$Resources:core,cui_STT_ButViewDocumentProperties;"

                    TemplateAlias="o1"/>

    Then render a section for the button at the layout tag like this:
    <Layout

                  Title="OneLargeTwoMedium"

                  LayoutTitle="OneLargeTwoMedium">

                  <Section Alignment="Top" Type="TwoRow">

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="cust1" />

                    </Row>

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="o1" />

                    </Row>

                  </Section>

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support



    Monday, December 5, 2011 10:33 AM
    Moderator

All replies

  • Hi Surya,

    The default ribbon groups and buttons are defined in CMDUI.xml file in the location of: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML, you can locate to it and have a check.

    To add existing button to a new group, you can copy the button in the CMDUI.xml file, then paste it to the new group definition file and render section for it, hidden the existing button.

    For example, I have a custom group for Shared Document library like this:
    <Groups Id="Ribbon.CustomTabExample.Groups">

                  <Group

                    Id="Ribbon.CustomTabExample.CustomGroupExample"

                    Description="This is a custom group!"

                    Title="Custom Group"

                    Sequence="52"

                    Template="Ribbon.Templates.CustomTemplateExample">

                    <Controls Id="Ribbon.CustomTabExample.CustomGroupExample.Controls">

                      <Button

                        Id="Ribbon.CustomTabExample.CustomGroupExample.HelloWorld"

                        Command="CustomTabExample.HelloWorldCommand"

                        Sequence="15"

                        Description="Says Hello to the World!"

                        LabelText="Hello, World!"

                        TemplateAlias="cust1"/>

                    </Controls>

                  </Group>

                </Groups>

    Then copy the existing button and paste it to the Groups tag, for example view properties button:
    <Button

                    Id="Ribbon.Documents.Manage.ViewProperties"

                    Sequence="10"

                    Command="ViewProperties"

                    Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-32" Image16by16Left="-80"

                    Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-96" Image32by32Left="-448"

                    LabelText="$Resources:core,ButViewProperties;"

                    ToolTipTitle="$Resources:core,ButViewProperties;"

                    ToolTipDescription="$Resources:core,cui_STT_ButViewDocumentProperties;"

                    TemplateAlias="o1"/>

    Then render a section for the button at the layout tag like this:
    <Layout

                  Title="OneLargeTwoMedium"

                  LayoutTitle="OneLargeTwoMedium">

                  <Section Alignment="Top" Type="TwoRow">

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="cust1" />

                    </Row>

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="o1" />

                    </Row>

                  </Section>

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support



    Monday, December 5, 2011 10:33 AM
    Moderator
  • Hi Qiao,

    Thanks for your response. I have created a custom group and tried to place the existing button in my new group with your idea, but id did not work for me. here is my xml and can you tell me where am missing. I also tried with two buttons as you mentioned above with layout tag. but to make it simple here I pasted just OOB button in my new group.

    /////

    <CustomAction
        Id="MyCustomAction"
        Location="CommandUI.Ribbon">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Tabs.PDP.Home.Groups._children">
              <Group
                Id="Ribbon.Tabs.PDP.Home.MyGroup"
                Sequence="55"
                Description="My Custom Group"
                Title="Project New group"
                Command="EnableMyGroup"
                Template="Ribbon.Templates.Flexible2">
                <Controls Id="Ribbon.Tabs.PDP.Home.MyGroup.Controls">
                   <Button
                    Id="Ribbon.Tabs.PDP.Home.GoTo.GoToProjectPermissions"
                    Command="PDPGoToProjectPermissions"
                    Sequence="20"
                    Image16by16="/_layouts/$Resources:core,Language;/images/ps16x16.png"
                    Image16by16Top="-80" Image16by16Left="-112"
                    Image32by32="/_layouts/$Resources:core,Language;/images/ps32x32.png"
                    Image32by32Top="-32" Image32by32Left="-224"
                    LabelText="$Resources:pwafeatures,PAGE_PDP_CM_GO_TO_PROJECT_PERMISSIONS"
                    TemplateAlias="c6"
                    ToolTipTitle="$Resources:pwafeatures,WEBPARTS_PROJECTDRILLDOWNPART_CM_GO_TO_PROJECT_PERMISSIONS"
                    ToolTipDescription="$Resources:pwafeatures,SUPER_TOOLTIP_PROJECT_PERMISSIONS"/>
               </Controls>
                </Group>
            </CommandUIDefinition>
            <CommandUIDefinition
              Location="Ribbon.Tabs.PDP.Home.Scaling._children">
              <MaxSize
                Id="Ribbon.Tabs.PDP.Home.Scaling.MyGroup.MaxSize"
                Sequence="15"
                GroupId="Ribbon.Tabs.PDP.Home.MyGroup"
                Size="LargeLarge" />
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
              Command="EnableMyGroup"
              CommandAction="javascript:return true;" />
            <CommandUIHandler
              Command="ClickOnIt"
              CommandAction="javascript:alert('Yes..');"
              EnabledScript="javascript: function AlwaysTrue(){return true;} AlwaysTrue();"/>
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>

    ////

    Monday, December 5, 2011 6:10 PM
  • Hi Surya,

    Thanks for posting back.

    There are some points that we need to pay attention here, first, the button that needs to be added to the group should be available on current page or item, otherwise, it will be gray and cannot be used; the button we add to the group need to be rendered a suitable section.

    Here is the all code I test as an example, it will create a group on Shared Documents library page, and I add the default ViewProperties button to the group, you can look into it for more information:
    <?xml version="1.0" encoding="utf-8"?>

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

      <CustomAction

       Id="MyCustomRibbonTab"

       Location="CommandUI.Ribbon.ListView"

       RegistrationId="101"

       RegistrationType="List">

        <CommandUIExtension>

          <CommandUIDefinitions>

            <CommandUIDefinition

              Location="Ribbon.Tabs._children">

              <Tab

                Id="Ribbon.CustomTabExample"

                Title="My Custom Tab"

                Description="This holds my custom commands!"

                Sequence="501">

                <Scaling

                              Id="Ribbon.CustomTabExample.Scaling">

                  <MaxSize

                    Id="Ribbon.CustomTabExample.MaxSize"

                    GroupId="Ribbon.CustomTabExample.CustomGroupExample"

                    Size="OneLargeTwoMedium"/>

                  <Scale

                    Id="Ribbon.CustomTabExample.Scaling.CustomTabScaling"

                    GroupId="Ribbon.CustomTabExample.CustomGroupExample"

                    Size="OneLargeTwoMedium" />

                </Scaling>

                <Groups Id="Ribbon.CustomTabExample.Groups">

                  <Group

                    Id="Ribbon.CustomTabExample.CustomGroupExample"

                    Description="This is a custom group!"

                    Title="Custom Group"

                    Sequence="52"

                    Template="Ribbon.Templates.CustomTemplateExample">

                    <Controls Id="Ribbon.CustomTabExample.CustomGroupExample.Controls">

     

                      <Button

                    Id="Ribbon.Documents.Manage.ViewProperties"

                    Sequence="10"

                    Command="ViewProperties"

                    Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-32" Image16by16Left="-80"

                    Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-96" Image32by32Left="-448"

                    LabelText="$Resources:core,ButViewProperties;"

                    ToolTipTitle="$Resources:core,ButViewProperties;"

                    ToolTipDescription="$Resources:core,cui_STT_ButViewDocumentProperties;"

                    TemplateAlias="o1"/>

                     

                      <Button

                        Id="Ribbon.CustomTabExample.CustomGroupExample.HelloWorld"

                        Command="CustomTabExample.HelloWorldCommand"

                        Sequence="15"

                        Description="Says Hello to the World!"

                        LabelText="Hello, World!"

                        TemplateAlias="cust1"/>

                    

                    </Controls>

                  </Group>

                </Groups>

              </Tab>

            </CommandUIDefinition>

            <CommandUIDefinition Location="Ribbon.Templates._children">

              <GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">

                <Layout

                  Title="OneLargeTwoMedium"

                  LayoutTitle="OneLargeTwoMedium">

                  <Section Alignment="Top" Type="TwoRow">

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="cust1" />

                    </Row>

                    <Row>

                      <ControlRef DisplayMode="Medium" TemplateAlias="o1" />

                    </Row>

                  </Section>

                </Layout>

              </GroupTemplate>

            </CommandUIDefinition>

          </CommandUIDefinitions>

          <CommandUIHandlers>

            <CommandUIHandler

              Command="CustomTabExample.HelloWorldCommand"

              CommandAction="javascript:alert('Hello, world!');" />

          </CommandUIHandlers>

        </CommandUIExtension>

      </CustomAction>

    </Elements>

     

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

    Tuesday, December 6, 2011 2:14 AM
    Moderator