当前位置: 主页 > Office办公 > 其他专区 > SharePoint > sharepoint 如何在Ribbon区添加功能按钮

sharepoint 如何在Ribbon区添加功能按钮

  • 2022-04-04
  • 来源/作者: 菜鸟图库/ 菜鸟图库
  • 297 次浏览

继续前面的一篇内容,sharepoint  如何在列表中添加功能菜单操作项,这次主要是记录下,在Ribbon区域添加功能按钮,例如添加收藏按钮,如下图所示:

sharepoint 如何在Ribbon区添加功能按钮
 

1。还是一样,添加一个空元素,CollectionRibbonItem

修改XML文件代码,在<elements></elements>标签中,添加CustomAction,

 

  <CustomAction

    Id="Ribbon.Library.Actions.AddAButton"

    Location="CommandUI.Ribbon"

    RegistrationId="101"

    RegistrationType="List"

    Title="Add a Ribbon Button">

    <CommandUIExtension>

      <CommandUIDefinitions>

        <CommandUIDefinition

          Location="Ribbon.Library.Share.Controls._children">

          <ButtonId="Ribbon.Library.Share.NewRibbonButton"

            Command="NewRibbonButtonCommand"

            Image16by16="/_layouts/15/2052/images/formatmap16x16.png"

            Image32by32="/_layouts/15/2052/images/formatmap32x32.png"

            LabelText="收藏"

            TemplateAlias="o2" />

        </CommandUIDefinition>

      </CommandUIDefinitions>

      <CommandUIHandlers>

        <CommandUIHandler

          Command="NewRibbonButtonCommand"

          EnabledScript="javascript:SetEnableRibbonSubscribe();"

          CommandAction="javascript:alert('Hello, world');" />

      </CommandUIHandlers>

    </CommandUIExtension>

  </CustomAction>

 

2。部署到网站上,就可以了。