So deaktivieren Sie eine Bandtaste, wenn ein Ordner ausgewählt ist
-
16-10-2019 - |
Frage
Ich habe dem SharePoint -Ribbon für Dokumentbibliotheken eine neue Schaltfläche hinzugefügt. Dies alles funktioniert gut und die Schaltfläche ist abhängig von der Anzahl der ausgewählten Elemente aktiviert / deaktiviert ... in Ordnung!
Ich möchte dies verbessern, indem ich die Schaltfläche deaktiviere, wenn ein Ordner ausgewählt ist, ähnlich wie die Standard -SharePoint -E -Mail -Schaltfläche 'E -Mail' eine Link 'funktioniert. Kann jemand Ratschläge geben, wie er sich daran nähert? Ich habe herumgegoogelt, konnte aber nichts finden.
Der Code, den ich derzeit habe, lautet wie folgt:
<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>
Lösung
Verwenden Sie das fsObjType
Eigentum:
EnabledScript="javascript:
var items = SP.ListOperation.Selection.getSelectedItems();
(items.length == 1 && items[0].fsObjType == 0);"
Andere Tipps
Können Sie alarmieren, was Sie erhalten, wenn Sie einen Ordner mit SP.Listoperation.Selection.GetSelectedItems () auswählen?