Domanda

I'm scratching my head at this problem. I can't work out how I need to register my custom action so that in the context of a page content type it will appear in the ribbon under the "File" tab (Ribbon.Document) in an active list view web part. I'd foolishly assumed that I wouldn't have to do anything special to achieve this, which was already working in the context of an actual view for a document library. This is a sandbox solution. I registered the action in my feature like this (leaving some stuff out and renaming anything identifiable):

<CustomAction Id="MyCompany.Publications.CustomActionsGroup"
        Location="CommandUI.Ribbon"
        RegistrationId="{$ListId:Publications;}"
        RegistrationType="List"
        Sequence="10001"
        Title="Actions">
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
      <Group Id="MyCompany.Publications.CustomActionsGroup" Description="" Title="Actions" Sequence="1" Template="Ribbon.Templates.Flexible2">
        <Controls Id="MyCompany.Publications.CustomActionsGroup.Controls">
          <Button Id="MyCompany.Publications.CustomActionsGroup.MyButton" .../>
        </Controls>
      </Group>
    </CommandUIDefinition>
    <CommandUIDefinition
      Location="Ribbon.Documents.Scaling._children">
      <MaxSize
        Id="PGS.Imaging.GeoNet.Scaling.Publications.CustomActionGroup.MaxSize"
        Sequence="10001"
        GroupId="PGS.Imaging.GeoNet.Publications.CustomActionsGroup"
        Size="LargeLarge" />
      </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
      <CommandUIHandler .../>
    </CommandUIHandlers>
  </CommandUIExtension>
</CustomAction>

As I said, this does work in the context of the actual document library. It's a new group that appears under the Files tab. I naively assumed it would also appear similarly for a web part page that contains a list view web part on that same document library. It does not. I've tried registering to the Pages list and then it appears in views for the Pages document library but not on an actual page. I tried using "ContentType" for RegistrationType and "0x" for RegistrationId (I can use javascript and CSS to limit where it appears), but that still does not appear in this context. Inspecting the HTML source shows that the hidden input for the tab I want to appear under is, as in the other context, given the value "Ribbon.Document". I have no idea what I'm missing here, but perhaps it's the value for the group template that's not working. Can anyone help? Many thanks.

È stato utile?

Soluzione

This turned out to be just something strange with the web part page possibly due to how it was initially created. It was first created as the Article Page content type but then it was changed to Welcome Page. There were issues creating the list view web part of which I'd been unaware, but as an experiment we tried just creating a new Welcome Page web part page and everything worked as expected. Beware. I've been surprised so many times by something not working as expected in SharePoint that it's not even really surprising any more. It causes one to question the expectation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top