首页 > 解决方案 > SharePoint 扩展命令集

问题描述

SharePoint 现代:是否可以使用特定列表的命令集添加自定义操作或如何激活特定列表的自定义操作? 我正在尝试为特定列表开发自定义操作,但是当我在 SharePoint 租户中部署此自定义操作时,会为所有列表(相同类型的列表模板)添加此自定义操作。

标签: sharepointoffice365sharepoint-onlinesharepointframework

解决方案


这是我将命令集扩展限制为特定列表的测试解决方案。

我们可以通过 获取当前列表标题this.context.pageContext.list.title

@override
  public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {    
    const compareOneCommand: Command = this.tryGetCommand('COMMAND_1');
    if (compareOneCommand) {
      // This command should be hidden unless exactly one row is selected.
      compareOneCommand.visible = this.context.pageContext.list.title === 'MyList3';      
    }
  }

一个类似的线程


推荐阅读