我有一个 SPFX webpart,它在启动时会从 SPO 列表中检索项目列表并显示它们:
const Owner = item.OwnerId;
var itemOwner = sp.web.getUserById(Owner).select("Title", "Owner/Title").expand("Owner").get().then(r => {
console.log(r, 'r');
}); //this successfully retrieves the title for each item,
but how would I implement it into the repeated list below in replacement of item.OwnerId?
return (
<div>
<tr>
<td style={{ width: '80px' }}>{item.Created}</td>
<td style={{ width: '100px' }}>{item.OwnerId}</td>
<td style={{ width: '100px' }}>{item.FormStatus}</td>
<td style={{ width: '15px' }}>
<div className={styles.editIcon}><Icon iconName="Edit" id={item.Id.toString()} onClick={this._editItem} />
</div>
</td>
</tr>
</div>
);
我想显示所有者列的标题而不是 ID。因此,我可以从 SPO 列表中检索所有者列的 ID,它将成功显示在项目列表中,但我无法理解如何扩展所有者列以显示所有者的标题。你可以在上面看到我是如何尝试的。但它显示一个错误。
我用于检索列表的数据模型和接口:
export interface IEIAItem {
....
Owner: string;
OwnerId: any;
....
}
export class EIAItem implements IEIAItem {
....
public Owner: string;
public OwnerId: any;
....
constructor(item: IEIAItem){
....
this.Owner=item.Owner;
this.OwnerId=item.OwnerId;
....
}
}