首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sharepoint spfx、onListViewUpdated()异步

Sharepoint spfx、onListViewUpdated()异步
EN

Stack Overflow用户
提问于 2020-06-24 19:40:16
回答 1查看 263关注 0票数 0

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

EN

回答 1

Stack Overflow用户

发布于 2020-06-26 15:11:40

检查此thread

代码语言:javascript
复制
@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;
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62554212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档