New Ribbon Tab Groups and their Templates

I had a curious problem today. I was registering Custom Actions to create a TabGroup with a single Button control on SharePoint’s ribbon:

I did this following Chris O’Brien’s post about “Adding ribbon items to existing tabs/groups“. It worked well, except that as we’re not registering the custom action against a particular list type (e.g. “101”), this button will appear on any list using the tab specified in the CommandUIDefinition‘s Location. In other words, for this example, any list with a ‘Library’ tab:

    <CustomAction Id="My.DocumentLibraryTab"
    Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Library.Groups._children">
          <Group Id="My.DocumentLibraryTab.ClassificationGroup"
            Sequence="45"
            Description="My Library Classification"
            Title="My"
            Template="Ribbon.Templates.Flexible">
            <Controls Id="My.DocumentLibraryTab.ClassificationGroup.Controls">
              <Button Id="My.DocumentLibraryTab.ClassificationGroup.ClassifyList"
                Command="My.Command.ClassifyList"
                Sequence="45"
                Image16by16="/_layouts/images/My/ClassifyList_16x16.png"
                Image32by32="/_layouts/images/My/ClassifyList_32x32.png"
                Description="Submit an entire Library for classification."
                LabelText="Classify Library"
                TemplateAlias="o1" />
            </Controls>
          </Group>
        </CommandUIDefinition>
      </CommandUIDefinitions>

This was a problem was, this button should only appear for a particular type of list. I changed the CustomAction to register against a particular type of list:

<CustomAction Id="Smartlogic.Semaphore.DocumentLibraryTab"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List">

However, now when I tried navigating to the tab on the list, the ribbon would show ‘Loading’ and hang, and a JavaScript error was thrown. What I found was this error was

Ribbon.Templates.Flexible could not be loaded

Interesting. Armed with that, I did some digging, and then as I came to the same conclusion, I found Andrew Connell’s post ‘Always Create Your Own Group Templates with SharePoint Ribbon Customizations’. The problem was that while I wasn’t registering my TabGroup against a particular type of list, the CMDUI.xml file was being loaded – so the out of the box templates were available. However, once I tried registering the tabgroup against a particular type of list, they weren’t loaded – so the template was unavailable, and hence just script.

So just do what Andrew Connell says – define your own. I ended up copying the one I wanted from CMDUI.xml and including it into my custom action.

Advertisements
New Ribbon Tab Groups and their Templates

2 thoughts on “New Ribbon Tab Groups and their Templates

  1. Peter says:

    Hi,

    Is there is a specific way to register the script?

    How did you end up “including it into my custom action”

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s