在 SharePoint 中,如何仅向特定列表显示自定义功能区按钮?

发布于 2024-11-30 22:44:28 字数 1222 浏览 1 评论 0原文

我有四个外部列表“List1”、“List2”、“List3”、“List4”。我添加了一个自定义功能区按钮,例如:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="ATEAgWorkOrderButton"
    RegistrationType="List"
    RegistrationId="600"
    Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListItem.Actions.Controls._children">
          <Button
           Id="Ribbon.ListItem.Actions.ATEAgWorkOrderButton"
           Alt="Click on this button to Add"
           Sequence="3"
           Image32by32="/_layouts/Images/Project/image.png"
           Command="ATEAg_WorkOrder"
           LabelText="Add Detail"
           TemplateAlias="o2"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
         Command="ATEAg_WorkOrder"
         CommandAction="javascript:alert("Hello Success");" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

该按钮现在在所有外部列表中可见。但我想让它仅对“List1”和“List2”可见。如何做到这一点?

I am having four external list "List1", "List2", "List3", "List4". I have added a custom ribbon button Like:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="ATEAgWorkOrderButton"
    RegistrationType="List"
    RegistrationId="600"
    Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListItem.Actions.Controls._children">
          <Button
           Id="Ribbon.ListItem.Actions.ATEAgWorkOrderButton"
           Alt="Click on this button to Add"
           Sequence="3"
           Image32by32="/_layouts/Images/Project/image.png"
           Command="ATEAg_WorkOrder"
           LabelText="Add Detail"
           TemplateAlias="o2"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
         Command="ATEAg_WorkOrder"
         CommandAction="javascript:alert("Hello Success");" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

The button is now visible in all the external lists. But I want to make it visible for only "List1" and "List2". How to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假面具 2024-12-07 22:44:28

您需要深入探索 Andrew Connell 的功能区自定义。

http://www .andrewconnell.com/blog/archive/2011/04/16/sharepoint-2010-ribbon-customization-deep-dive.aspx

他进入如何解决这些问题。简而言之,您可以注册一个 JavaScript 函数,调用该函数来确定是否应显示或隐藏按钮,而不是绑定特定类型的所有列表的自定义。在此功能中,您可以确定当前处于活动状态的列表。

You need to explore the Andrew Connell's Ribbon Customization Deep Dive.

http://www.andrewconnell.com/blog/archive/2011/04/16/sharepoint-2010-ribbon-customization-deep-dive.aspx

He goes into how to solve these problems. In short instead of binding a customization for all lists of a certain type, you can register a javascript function that gets called to determine if you button should be shown or hidden. In this function you can determine which list is currently active.

初与友歌 2024-12-07 22:44:28

如果您的所有列表都与 ContentType 关联,您可以将自定义操作的注册 ID 设置为 ContentType ID。

来自 MSDN

RegistrationID:可选文本。指定列表的标识符或
与此操作关联的项目内容类型或文件
类型或编程标识符 (ProgID)。

If all your lists are associated with a ContentType, you can set the registration id of the custom action to the ContentType id.

From MSDN:

RegistrationID: Optional Text. Specifies the identifier of the list or
item content type that this action is associated with, or the file
type or programmatic identifier (ProgID).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文