Using the default
template in the Get component, the whole result is returned. When using React Graph Toolkit components, how can I loop through this result set in the template created, and create f.ex. Person components for each result item?
Asked
Active
Viewed 324 times
0
1 Answers
0
If you're fetching /user
resource and the result is an array, then the value
template will be more suitale:
const LoadingPerson = (props: MgtTemplateProps) => {
return <div><Spinner size={SpinnerSize.large} label="Loading members..." /></div>;
};
const MemberPerson = (props: MgtTemplateProps) => {
const person = props.dataContext;
return <div>
<Person userId={person.userPrincipalName} view={PersonViewType.twolines} fetchImage={true} showPresence={true}
personCardInteraction={PersonCardInteraction.hover} line2Property="mail"></Person>
</div>;
};
<Get resource="/users" scopes={["User.Read.All"]}>
<MemberPerson template="value" />
<LoadingPerson template="loading" />
</Get>
More reference:

Baker_Kong
- 1,739
- 1
- 4
- 9
-
Thanks! I'm already using the `value` template. But I need to sort the result set before rendering it. How can I achieve this? I have been told to use the `default` template, ref this thread: https://stackoverflow.com/questions/64573688/working-example-for-graph-toolkit-using-sharepoint-spfx-react-and-get-component – Frank-Ove Kristiansen Jan 04 '21 at 10:56