Adding Custom Ribbon Tab To the SharePoint 2013 Server Ribbon

Posted: April 7, 2015 in SharePoint2013

Introduction 

In this article we will explore to how to create a custom tab in SharePoint 2013 Custom Action Ribbon.

I wanted to create a Custom Action Tab in my SharePoint Hosted app. Consider that SharePoint 2013 already provides a home that may be suitable for your customization, for list pages at least; the Custom Commands tab. It only appears on list pages and contains just one lonely button under normal circumstances. This tab is actually the post-upgrade home for any SharePoint 2007 CustomActions you had, assuming you don’t introduce changes during your upgrade process, any CustomActions that didn’t target the ECB will end up here. In any case, it could help avoid tab proliferation so don’t forget it when building your customizations.

Solutions

  1. Add a ribbon custom action for the App project that you have created. Right click on the project [Add] [New Item] [Ribbon Custom Action] and enter the Name and click on the Add button. It will start the wizard for creating a custom action for the Ribbon control.

    custom action for Ribbon

  2. In this wizard select the host web where you want to expose the custom action. In other words your custom action will be available in that host web.

    The custom action scoped can be a List template or a List instance or None. In this example I am selecting List template and the item is the custom action scoped to be “Custom list”.

    custom list

  3. Selected “Ribbon.ListItem.Actions”. What this does is, it will show the custom action under the Items section of the List Ribbon control.

    ribbon list item

  4. The following is the Custom Ribbon XML that I created for the Custom Tab. Refer to the Ribbon XML Schema for more options: Server Ribbon schema.
    1. <?xml version=“1.0” encoding=“utf-8”?>
    2. <Elements xmlns=http://schemas.microsoft.com/sharepoint/&#8221;>
    3.   <CustomAction Id=“Team Collaborate”
    4.                 RegistrationType=“List”
    5.                 RegistrationId=“100”
    6.                 Location=“CommandUI.Ribbon”
    7.                 Sequence=“10001”
    8.                 Title=“Team Collaborate”
    9.               >
    10.     <CommandUIExtension>
    11.       <CommandUIDefinitions>
    12.         <CommandUIDefinition Location=“Ribbon.Tabs._children”>
    13.           <Tab Id=“Team Collaborate.Tab”
    14.                 Title=“Team Collaborate”
    15.                 Description=“Special Risk Tracking Functionality”
    16.                 Sequence=“550”>
    17.             <Scaling Id=“Team Collaborate.Tab.Scaling”>
    18.               <MaxSize Id=“Team Collaborate.Tab.EnterpriseRiskGroup.MaxSize”
    19.                         GroupId=“Team Collaborate.Tab.EnterpriseRiskGroup”
    20.                         Size=“OneLarge”/>
    21.               <Scale Id=“Team Collaborate.Tab.EnterpriseRiskGroup.Scaling.CustomTabScaling”
    22.                       GroupId=“Team Collaborate.Tab.EnterpriseRiskGroup”
    23.                       Size=“OneLarge” />
    24.             </Scaling>
    25.             <Groups Id=“Team Collaborate.Tab.Groups”>
    26.               <Group Id=“Team Collaborate.Tab.EnterpriseRiskGroup”
    27.                       Description=“Functions that can be performed on Enterprise Risks”
    28.                       Title=“Sharepoint Consulting”
    29.                       Sequence=“10”
    30.                       Template=“Ribbon.Templates.OneLargeExample”>
    31.                 <Controls Id=“Team Collaborate.Tab.EnterpriseRiskGroup.Controls”>
    32.                   <Button Id=“Team Collaborate.Tab.EnterpriseRiskGroup.Notify”
    33.                           Command=“Team Collaborate.EnterpriseRisk”
    34.                           Sequence=“10”
    35.                           Image16by16=“_layouts/15/TeamCollaborate.png”
    36.                           Image32by32=“_layouts/15/TeamCollaborate.png”
    37.                           Description=“Selected Largest Team of Certified SharePoint developers.”
    38.                           LabelText=“Expert Sharepoint”
    39.                           TemplateAlias=“cust1”/>
    40.                 </Controls>
    41.               </Group>
    42.             </Groups>
    43.           </Tab>
    44.         </CommandUIDefinition>
    45.         <CommandUIDefinition Location=“Ribbon.Templates._children”>
    46.           <GroupTemplate Id=“Ribbon.Templates.OneLargeExample”>
    47.             <Layout Title=“OneLarge” LayoutTitle=“OneLarge”>
    48.               <Section Alignment=“Top” Type=“OneRow”>
    49.                 <Row>
    50.                   <ControlRef DisplayMode=“Large” TemplateAlias=“cust1” />
    51.                 </Row>
    52.               </Section>
    53.             </Layout>
    54.           </GroupTemplate>
    55.         </CommandUIDefinition>
    56.       </CommandUIDefinitions>
    57.       <CommandUIHandlers>
    58.         <CommandUIHandler Command=“Team Collaborate.EnterpriseRisk”
    59.                         CommandAction=“~remoteAppUrl/Pages/TeamCollaborate.aspx?{StandardTokens}&Source={Source}&ListURLDir={ListUrlDir}&list={ListId}&SelectedItems={SelectedItemId}” />
    60.       </CommandUIHandlers>
    61.     </CommandUIExtension>
    62.   </CustomAction>
    63. </Elements>
  5. Build and publish App and add into the apps in the Testing Library and deploy; Trust it.

    Testing Library

    app in testing

    Testing Library and deploy

    The following shows the final output Custom Ribbon Tab:

    Custom Ribbon

Summary

The ribbon is a key building block for SharePoint 2013 solutions and if you see a ribbon tab for a Custom List on the Ribbon Control Bar then it can be customized.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s