質問

ドキュメントライブラリ用のSharePointリボンに新しいボタンを追加しました。これはすべてうまく機能し、選択したアイテムの数に応じてボタンが有効 /無効になります...罰金!

標準のSharePointの「リンクを電子メールで送信する」ボタンの動作と同様に、フォルダーが選択されているときにボタンを無効にすることにより、これを改善したいと思います。誰もがこれにアプローチする方法について何かアドバイスを提供できますか?私は周りにグーグルで検索しましたが、何も見つけることができませんでした。

私が現在持っているコードは次のとおりです。

  <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&amp;ListId={ListId}&amp;ItemId=' + SP.ListOperation.Selection.getSelectedItems()[0].id + '&amp;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 &amp;&amp; items[0].fsObjType == 0);"

他のヒント

sp.listoperation.selection.getSelectedItems()を使用してフォルダーを選択したときに何を得ることができますか。

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top