自定义标签中的registrationId属性的多个值
-
16-10-2019 - |
题
我想知道有没有能力设置一个,而且可以设置多个值 RegistrationId
在 CustomAction
标签。
我有一个elements.xml条目:
<CustomAction
Id="ClassifyDialogButton.SharePoint.Ribbon.CustomTab"
Location="CommandUI.Ribbon"
Rights="EditListItems"
RegistrationType="List"
RegistrationId="101">
有人知道如何修改它以添加另外两个registrations?
解决方案
一般而言,XML属性并非具有多个值。
有趣的是,属性 似乎是可选的, ,因此,可以通过排除(可能太多)将其一次应用于许多地方。
我唯一的其他建议是做一个很好的老式复制纸,并为每个登记ID提供一个自定义元素。
其他提示
您真正想要的是 SharePoint 2010 Fluent Ribbon API. 。这是一个编码器项目,可以简化功能区工作。它具有深入的文档,包括大量样品和屏幕截图。
该解决方案的唯一坏事是,您应该将XML功能区定义重写为Fluentribbon功能区定义。但是代码定义更加灵活,并且Fluentribbon还提供了一些额外的功能:简化的语法,全长文档和定性验证,因此IMO,值得。
在您的情况下,生成的代码将看起来像这样(内部功能接收器类,在特征反应方法中):
var myTab = new TabDefinition
{
Id = "MyTab",
Title = "My tab",
// etc, create your definition here...
};
// instantiate RibbonCustomAction class
var ribbonCustomAction = new RibbonCustomAction();
// add one or more ribbon definitions, which will be deployed
// in same scope.
// RibbonCustomAction acts like a container for such definitions.
ribbonCustomAction.AddTab(myTab);
// Let's provision our custom action
// receiverGuid is a random constant Guid, which must be unique
// in the feature scope. It is used for cleanup in FeatureDeactivating
// method.
ribbonCustomAction.Provision(
receiverGuid,
web,
ListTypes.GenericLibrary,
ListForms.All,
SPBasePermissions.ManageLists);
// Next, we can provision the same custom action again and again to different
// locations. For example, let's register it for Links list:
ribbonCustomAction.Provision(
receiverGuid,
web,
ListTypes.LinksList,
ListForms.All,
SPBasePermissions.ManageLists);
顺便提一句, 条款 方法具有许多过载,在最简单的情况下,您只能提供2-3个参数。
您可以找到更多样品 在项目网站.
PS请,请不要忘记添加对ribbonutils.dll的引用并将记录添加到GAC部署列表中(package.package,“高级选项卡”,添加 - >现有汇编)
这可以通过复制“自定义XML”部分来完成。只需复制整个自定义操作部分,并在第1个自定义XML部分下方粘贴,然后将IncmistrationID更改为您希望它出现的下一个registrationID即可。