Adding a Control on a Custom Tab to the Server Ribbon : SharePoint 2010

Adding a Control on a Custom Tab to the Server Ribbon : SharePoint 2010

Code :

<?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.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="OneRow">

                <Row>

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

                </Row>

              </Section>

              
            </Layout>

          </GroupTemplate>

        </CommandUIDefinition>
        
      </CommandUIDefinitions>

      <CommandUIHandlers>
        
        <CommandUIHandler
          Command="CustomTabExample.HelloWorldCommand"
          CommandAction="javascript:alert('Hello, world!');" />
        
      </CommandUIHandlers>
      
    </CommandUIExtension>
    
  </CustomAction>
  
</Elements>
Advertisements

Tags: , , , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: