0

我正在为在线共享点创建一个提供程序托管的加载项,我想创建按钮,或者如果可能的话,最好在命令栏中创建一个下拉按钮,如下所示:

在此处输入图像描述

也许这个问题已经被问过很多次了,但我找不到任何明确的答案。

到目前为止,我可以在使用 Visual Studio 创建自定义操作的项目的上下文菜单中创建按钮。

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="2bd189ad-3561-405e-815e-39f1a7fa1548.MenuItemCustomAction2"
                RegistrationType="List"
                RegistrationId="101"
                Location="EditControlBlock"
                Sequence="10001"
                Title="Invoke &apos;MenuItemCustomAction2&apos; action">
    <!-- 
    Update the Url below to the page you want the custom action to use.
    Start the URL with the token ~remoteAppUrl if the page is in the
    associated web project, use ~appWebUrl if page is in the app project.
    -->
    <UrlAction Url="~remoteAppUrl/WebForm1.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}" />
  </CustomAction>
</Elements>

但我找不到类似的命令栏。我没有使用 sfpx,因为据我了解,它仅适用于共享点托管应用程序。

感谢您的帮助。

4

2 回答 2

0

@alejandro 格瓦拉,

您可以使用 PnP 配置引擎和自定义操作将下拉命令栏添加到库页面。

在此处输入图像描述

BR

于 2021-02-08T08:02:07.717 回答
0

感谢@Baker_Kong_MSFT 的想法。我用 Visual Studio 创建了一个功能区按钮,如果将来有人想要,这就是 xml 代码的外观。

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="9b50e988-bfdd-4415-a883-4e645c642d49.RibbonCustomAction1"
                RegistrationType="ContentType"
                RegistrationId="0x0101"
                Location="CommandUI.Ribbon"
                Sequence="10001"
                Title="Invoke RibbonCustomAction action">
    <CommandUIExtension>
      <!-- 
      Update the UI definitions below with the controls and the command actions
      that you want to enable for the custom action.
      -->
        <CommandUIDefinitions>
            <CommandUIDefinition Location="Ribbon.Tabs._children">
                <Tab Id="Custom Tab" Title="Custom Tab" Description="Custom Tab">
                    <Scaling Id="Custom Tab.Scaling">
                        <MaxSize Id="Custom Group.Scaling.MaxSize" GroupId="Custom Group" Size="TwoLarge" />
                        <MaxSize Id="Custom Group 2.Scaling.MaxSize" GroupId="Custom Group 2" Size="OneLarge" />
                        <Scale Id="Custom Group.Scaling.Scale" GroupId="Custom Group" Size="TwoLarge" />
                        <Scale Id="Custom Group 2.Scaling.Scale" GroupId="Custom Group 2" Size="OneLarge" />
                    </Scaling>
                    <Groups Id="Custom Tab.Groups">
                        <Group Id="Custom Group 2" Title="Custom Group 2" Description="Custom Group 2" Sequence="7888" Template="Ribbon.Templates.OneLarge">
                            <Controls Id="Custom Group 2.Controls">
                                <Button Id="CustomButton3" LabelText="Custom Button 3" Image16by16="/_layouts/15/images/attach16.png" Image32by32="/_layouts/15/images/attach16.png" ToolTipTitle="Custom Button 3" ToolTipDescription="Custom Button 3" Command="CustomButton3.Command" TemplateAlias="c3" />
                            </Controls>
                        </Group>
                        <Group Id="Custom Group" Title="Custom Group 1" Description="Custom Group 1" Sequence="10000" Template="Ribbon.Templates.TwoLarge">
                            <Controls Id="Custom Group 1.Controls">
                                <Button Id="CustomButton1" LabelText="Custom Button 1" Image16by16="/_layouts/15/images/itslidelibrary.png" Image32by32="/_layouts/15/images/itslidelibrary.png" ToolTipTitle="Custom Button 1" ToolTipDescription="Custom Button 1" Command="CustomButton1.Command" TemplateAlias="c1" />
                                <Button Id="CustomButton2" LabelText="Custom Button 2" Image16by16="/_layouts/15/images/dldsln16.png" Image32by32="/_layouts/15/images/dldsln16.png" ToolTipTitle="Custom Button 2" ToolTipDescription="Custom Button 2" Command="CustomButton2.Command" TemplateAlias="c2" />
                            </Controls>
                        </Group>
                    </Groups>
                </Tab>
            </CommandUIDefinition>
            <CommandUIDefinition Location="Ribbon.Templates._children">
                <GroupTemplate Id="Ribbon.Templates.TwoLarge">
                    <Layout Title="TwoLarge" LayoutTitle="TwoLarge">
                        <Section Alignment="Top" Type="OneRow">
                            <Row>
                                <ControlRef DisplayMode="Large" TemplateAlias="c1" />
                                <ControlRef DisplayMode="Large" TemplateAlias="c2" />
                            </Row>
                        </Section>
                    </Layout>
                </GroupTemplate>
            </CommandUIDefinition>
            <CommandUIDefinition Location="Ribbon.Templates._children">
                <GroupTemplate Id="Ribbon.Templates.OneLarge">
                    <Layout Title="OneLarge" LayoutTitle="OneLarge">
                        <Section Alignment="Top" Type="OneRow">
                            <Row>
                                <ControlRef DisplayMode="Large" TemplateAlias="c3" />
                            </Row>
                        </Section>
                    </Layout>
                </GroupTemplate>
            </CommandUIDefinition>
        </CommandUIDefinitions>
        <CommandUIHandlers>
            <CommandUIHandler Command="CustomButton1.Command" CommandAction="https://contoso.azurewebsites.net/pages/index.aspx" />
            <CommandUIHandler Command="CustomButton2.Command" CommandAction="http://www.bing.com" />
            <CommandUIHandler Command="CustomButton3.Command" CommandAction="https://developer.microsoft.com/sharepoint" />
        </CommandUIHandlers>
    </CommandUIExtension >
  </CustomAction>
</Elements>

在此处输入图像描述

于 2021-02-08T10:30:11.867 回答