选择文件夹时如何禁用功能区按钮
-
16-10-2019 - |
题
我为文档库的SharePoint功能区添加了一个新按钮。这一切都很好,并且根据所选项目数量启用 /禁用按钮...好!
I want to improve this by disabling the button when a folder is selected similar to how the standard SharePoint 'email a link' button works.谁能就如何解决这个问题提供任何建议?我已经谷歌搜索了,但找不到任何东西。
我目前拥有的代码如下:
<CustomAction
Id="Muhimbi.SharePoint.DocumentConverter.PDF.Ribbon.Documents.Copies.Controls.ConvertAndDownload.Action"
Location="CommandUI.Ribbon"
RegistrationType="ContentType"
RegistrationId="0x0101"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.Copies.Controls._children">
<Button Id="Muhimbi.SharePoint.DocumentConverter.PDF.Ribbon.Documents.Copies.Controls.ConvertAndDownload.Button"
Command="Muhimbi.SharePoint.DocumentConverter.PDF.Ribbon.Documents.Copies.Controls.ConvertAndDownload.Button.Command"
Image16by16="/_layouts/images/Muhimbi.PDFConverter/pdf16.gif"
Image32by32="/_layouts/images/Muhimbi.PDFConverter/pdf32.gif"
LabelText="$Resources:ecb_title;"
Sequence="12"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Muhimbi.SharePoint.DocumentConverter.PDF.Ribbon.Documents.Copies.Controls.ConvertAndDownload.Button.Command"
CommandAction="javascript:window.location='{SiteUrl}/_layouts/Muhimbi.PDFConverter/Convert.aspx?action=ConvertAndDownload&ListId={ListId}&ItemId=' + SP.ListOperation.Selection.getSelectedItems()[0].id + '&Source=' + window.location"
EnabledScript="javascript:function singleEnable()
{
var items = SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
return (ci == 1);
}
singleEnable();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
解决方案
使用 fsObjType
财产:
EnabledScript="javascript:
var items = SP.ListOperation.Selection.getSelectedItems();
(items.length == 1 && items[0].fsObjType == 0);"
其他提示
使用sp.listoperation.selection.getSelectedItems()选择一个文件夹时,您可以提醒您会得到什么;