特定Sharepoint列表的自定义操作菜单

7

我希望我的自定义操作菜单只应用于特定的列表;目前它是通过以下 XML 指定的,并且应用于所有列表!

更具体地说,我甚至希望此自定义操作适用于特定列表的特定视图...

<CustomAction
    Id="MyCustomActionId"
    Title="My Custom Action"
    Description="My Custom Action Description"
    RequireSiteAdministrator="FALSE"
    RegistrationType="List"
    GroupId="ActionsMenu"
    Sequence="1000"
    Location="Microsoft.SharePoint.StandardMenu" >
    <UrlAction Url="{SiteUrl}/_layouts/MySharepointArtifacts/MyCustomAction.aspx?ListId={ListId}"/>
  </CustomAction>

我该怎么做?

我已经安装了stsadm扩展来修复查找字段。添加另一个扩展应该没问题。我能通过Sharepoint对象模型访问正在配置的自定义操作吗? - Khurram Aziz
我还尝试在列表的 schema.xml(List / Views / ViewHeader)中添加链接,用户已经接受了它。在那里,我需要知道 ~site moniker 的 UrlAction 等效项以在 <HTML /> 中使用。 - Khurram Aziz
2个回答

9
创建一个内容类型(基于您想要在其上创建ECB菜单的项目),并将内容类型添加到列表中。创建一个customAction并将其注册到内容类型。在添加了内容类型的列表中,ECB菜单仅会显示在给定内容类型的项上。
以下是基于内置文档内容类型的内容类型示例:
    <?xml version="1.0" encoding="utf-8"?>
<Elements Id="f55bc095-86f5-4c0a-961e-0e8f8e6c50ed" xmlns="http://schemas.microsoft.com/sharepoint/">
  <ContentType ID="0x0101002936a05e70da4cf2a6846c669da7fdb6"
               Name="CTName"
               Group="CT group Name"
               Description="CT description"
               Version="0">
    <FieldRefs>...

创建一个自定义操作以应用于内容类型(参考内容类型ID):

    <CustomAction
        Id="MyCustomActionId"
        Title="My Custom Action"
        Description="My Custom Action Description"
        RequireSiteAdministrator="FALSE"
        RegistrationType="ContentType"
RegistrationId="0x0101002936a05e70da4cf2a6846c669da7fdb6"
        GroupId="ActionsMenu"
        Sequence="1000"
        Location="EditControlBlock" >
        <UrlAction Url="{SiteUrl}/_layouts/MySharepointArtifacts/MyCustomAction.aspx?ListId={ListId}"/>
      </CustomAction>

2
我可能错了,但对我来说,这段代码只能在“Location = EditControlBlock”下工作。 - brentlightsey
@lividsquirrel是正确的 - 通过上述方法将CustomAction锁定到特定的Content Type ID时,当Location="Microsoft.SharePoint.StandardMenu"和GroupId="ActionsMenu"时不起作用,但当Location="EditControlBlock"时它确实起作用(正如@lividsquirrel所述)。 - John Berberich
使用Location="EditControlBlock"是正确的,这样才能使其正常工作。我会更新我的答案。 - Tomso

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接