我需要在ListView命令集扩展中实现一个按钮,该按钮只有在用户对列表中的选定项具有编辑权限时才可见。因此,我必须在onListViewUpdated()方法中进行异步api调用,但我似乎无法工作,因为onListViewUpdated()不能用作aync函数。有谁有解决这个问题的办法吗?
发布于 2020-06-26 15:11:40
检查此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;
}
}https://stackoverflow.com/questions/62554212
复制相似问题