您如何创建将出现在各种列表上的功能区按钮自定义操作
-
16-10-2019 - |
题
我想创建一个功能区按钮,该按钮将与各种列表一起使用。我的意思是,相同的自定义操作应针对列表,文档库,公告列表等。
还。无论列表中包含的内容类型如何,它都应该工作。
自定义动作定义应该是什么?
解决方案
只需将其连接到0x01内容类型。
我们的SharePoint Audit Suite中使用的语法示例如下:
<!-- Add a new action to the SharePoint 2010 Ribbon bar for each list to show all audit entries for a list Item -->
<CustomAction
Id="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Action"
Location="CommandUI.Ribbon"
RegistrationType="ContentType"
RegistrationId="0x01"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.Share.Controls._children">
<Button Id="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button"
Command="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button.Command"
Image16by16="/_layouts/images/Muhimbi.SharePointAudit/Report16.gif"
Image32by32="/_layouts/images/Muhimbi.SharePointAudit/Report.gif"
LabelText="$Resources:MuhimbiAuditProvisioningResources,ECB_ViewAuditLog;"
Sequence="11"
TemplateAlias="o1" />
</CommandUIDefinition>
<CommandUIDefinition
Location="Ribbon.ListItem.Share.Controls._children">
<Button Id="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button"
Command="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button.Command"
Image16by16="/_layouts/images/Muhimbi.SharePointAudit/Report16.gif"
Image32by32="/_layouts/images/Muhimbi.SharePointAudit/Report.gif"
LabelText="$Resources:MuhimbiAuditProvisioningResources,ECB_ViewAuditLog;"
Sequence="11"
TemplateAlias="o1" />
</CommandUIDefinition>
<CommandUIDefinition
Location="Ribbon.Calendar.Events.Share.Controls._children">
<Button Id="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button"
Command="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button.Command"
Image16by16="/_layouts/images/Muhimbi.SharePointAudit/Report16.gif"
Image32by32="/_layouts/images/Muhimbi.SharePointAudit/Report.gif"
LabelText="$Resources:MuhimbiAuditProvisioningResources,ECB_ViewAuditLog;"
Sequence="11"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Muhimbi.SharePoint.Audit.Ribbon.ListItem.Share.ViewAuditLog.Button.Command"
CommandAction="javascript:window.location='{SiteUrl}/_layouts/Muhimbi.SharePointAudit.Site/AuditLogViewer.aspx?RequestFrom=listitem&ItemId=' + SP.ListOperation.Selection.getSelectedItems()[0].id + '&ListId={ListId}&Source=' + escape(window.location)"
EnabledScript="javascript:function singleEnable()
{
var items = SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
return (ci == 1);
}
singleEnable();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
其他提示
我使用了一种略有不同的方法。我只需要使用一个定义来添加到现在和将来的所有不同列表类型中。
http://djeeg.blogspot.com/2011/01/ribbon-customaction-on-all-lists.html