当通过功能元素注册自定义操作时,为什么 SPSite、SPWeb 和 SPList 的 UserCustomActions 为空.xml?



我制作了一个功能,通过elements.xml文件安装自定义操作(在SPWeb中安装并激活它)。

<CustomAction Id="ChangeBrowseTabTitle"
Location="CommandUI.Ribbon" 
RegistrationType="List"
RegistrationId="100">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">
<Button Id="Ribbon.ListItem.New.RibbonTest"
Alt="Test Button"
Sequence="5"
Command="Test_Button"
LabelText="Import"
Image32by32="~site/SiteAssets/EM.SharePoint.ImportList/fileimport32.png"
Image16by16="~site/SiteAssets/EM.SharePoint.ImportList/fileimport16.png"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Test_Button" CommandAction="javascript:alert('That's me!');" />
</CommandUIHandlers>
</CommandUIExtension>

然后我运行了一个控制台应用程序,检查了所有的

  • SPSite.UserCustomActions
  • SPWeb.UserCustomActions
  • SPList.UserCustomActions

在web中,我在其中注册了自定义操作。

但是所有UserCustomActions集合都是空的。

有人遇到过这样的魔法吗?

(该测试于2013年10月在SharePoint 2013 Foundation上进行)。

这不是魔法。您在这些集合中都看不到您的自定义操作,因为您的自定义动作已注册到列表模板(列表模板id=100-一般列表),而不是特定列表、网站或网站。如果你想在SharePoint中凝胶化所有自定义操作,请查看这篇文章,但有点棘手。

最新更新