【问题标题】:Sharepoint spfx, onListViewUpdated() asyncSharepoint spfx,onListViewUpdated() 异步
【发布时间】:2020-06-26 15:11:39
【问题描述】:

我需要在 ListView 命令集扩展中实现一个按钮,该按钮仅在用户对列表中的选定项目具有编辑权限时才可见。因此我必须在 onListViewUpdated() 方法中进行异步 api 调用,但我似乎不起作用,因为 onListViewUpdated() 不能用作 aync 函数。有没有人可以解决这个问题?

【问题讨论】:

    标签: sharepoint spfx


    【解决方案1】:

    检查这个thread

    @override
    public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
      // Get commands
      const commandOne: Command = this.tryGetCommand('COMMAND_1');
      const commandTwo: Command = this.tryGetCommand('COMMAND_2');
    
      // Command checks
      if (commandOne) {
        this._hideCommandByPermissionSet(commandOne, SPPermission.editListItems);
      }
      if (commandTwo) {
        this._hideCommandByPermissionSet(commandTwo, SPPermission.approveItems);
      }
    }
    
    private _hideCommandByPermissionSet(crntCommand: Command, permission: SPPermission) {
      if (this.context.pageContext.list.permissions.hasPermission(permission)) {
        crntCommand.visible = true;
      } else {
        crntCommand.visible = false;
      }
    }
    

    【讨论】:

    • 嗨@Lee_MSFT 我已经检查并评论了该线程(检查最新评论;-))。在您的示例和线程中,检查列表权限,但不检查列表中项目的权限。这是两件不同的事情,我需要检查用户是否具有列表中某些项目的编辑权限。
    猜你喜欢
    • 2018-09-14
    • 2019-01-09
    • 2021-09-30
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    相关资源
    最近更新 更多