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
Solutions
- 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.
- 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". - Selected "Ribbon.ListItem.Actions". What this does is, it will show the custom action under the Items section of the List Ribbon control.
- 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.
- <?xml version="1.0" encoding="utf-8"?>
- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
- <CustomAction Id="Team Collaborate"
- RegistrationType="List"
- RegistrationId="100"
- Location="CommandUI.Ribbon"
- Sequence="10001"
- Title="Team Collaborate"
- >
- <CommandUIExtension>
- <CommandUIDefinitions>
- <CommandUIDefinition Location="Ribbon.Tabs._children">
- <Tab Id="Team Collaborate.Tab"
- Title="Team Collaborate"
- Description="Special Risk Tracking Functionality"
- Sequence="550">
- <Scaling Id="Team Collaborate.Tab.Scaling">
- <MaxSize Id="Team Collaborate.Tab.EnterpriseRiskGroup.MaxSize"
- GroupId="Team Collaborate.Tab.EnterpriseRiskGroup"
- Size="OneLarge"/>
- <Scale Id="Team Collaborate.Tab.EnterpriseRiskGroup.Scaling.CustomTabScaling"
- GroupId="Team Collaborate.Tab.EnterpriseRiskGroup"
- Size="OneLarge" />
- </Scaling>
- <Groups Id="Team Collaborate.Tab.Groups">
- <Group Id="Team Collaborate.Tab.EnterpriseRiskGroup"
- Description="Functions that can be performed on Enterprise Risks"
- Title="Sharepoint Consulting"
- Sequence="10"
- Template="Ribbon.Templates.OneLargeExample">
- <Controls Id="Team Collaborate.Tab.EnterpriseRiskGroup.Controls">
- <Button Id="Team Collaborate.Tab.EnterpriseRiskGroup.Notify"
- Command="Team Collaborate.EnterpriseRisk"
- Sequence="10"
- Image16by16="_layouts/15/TeamCollaborate.png"
- Image32by32="_layouts/15/TeamCollaborate.png"
- Description="Selected Largest Team of Certified SharePoint developers."
- LabelText="Expert Sharepoint"
- TemplateAlias="cust1"/>
- </Controls>
- </Group>
- </Groups>
- </Tab>
- </CommandUIDefinition>
- <CommandUIDefinition Location="Ribbon.Templates._children">
- <GroupTemplate Id="Ribbon.Templates.OneLargeExample">
- <Layout Title="OneLarge" LayoutTitle="OneLarge">
- <Section Alignment="Top" Type="OneRow">
- <Row>
- <ControlRef DisplayMode="Large" TemplateAlias="cust1" />
- </Row>
- </Section>
- </Layout>
- </GroupTemplate>
- </CommandUIDefinition>
- </CommandUIDefinitions>
- <CommandUIHandlers>
- <CommandUIHandler Command="Team Collaborate.EnterpriseRisk"
- CommandAction="~remoteAppUrl/Pages/TeamCollaborate.aspx?{StandardTokens}&Source={Source}&ListURLDir={ListUrlDir}&list={ListId}&SelectedItems={SelectedItemId}" />
- </CommandUIHandlers>
- </CommandUIExtension>
- </CustomAction>
- </Elements>
- Build and publish App and add into the apps in the Testing Library and deploy; Trust it.
The following shows the final output Custom Ribbon Tab:
SummaryThe 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.