Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List view does not render people display name on people field #340

Closed
Ameralajore opened this issue Jul 23, 2019 · 4 comments
Closed

List view does not render people display name on people field #340

Ameralajore opened this issue Jul 23, 2019 · 4 comments

Comments

@Ameralajore
Copy link

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the documentation to see if your question is already addressed there. This will help us ensure our documentation is up to date.

Category

[ ] Enhancement

[ ] Bug

[ ] Question

Version

Please specify what version of the library you are using: [ ]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please
describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!

Observed Behavior

If you are reporting an issue please describe the behavior you expected to occur when performing the action. If you are making a
suggestion or asking a question delete this section.

Steps to Reproduce

If you are reporting an issue please describe the steps to reproduce the bug in sufficient detail to allow testing. If you are making
a suggestion or asking a question delete this section.

Submission Guidelines

Delete this section after reading

  • All suggestions, questions and issues are welcome, please let us know what's on your mind.
  • Remember to include sufficient details and context.
  • If you have multiple suggestions, questions, or bugs please submit them in separate issues so we can track resolution.

Thanks!

@ghost
Copy link

ghost commented Jul 23, 2019

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Jul 23, 2019
@Ameralajore
Copy link
Author

I have a list with people field when render it with list view it returns ID, so I override the render of the field to a function that took the ID and return the Display name, the function correctly return the Display name but the list view return does not render it.

@michaelmaillot
Copy link
Collaborator

Hi @Ameralajore,

In order to display person fields, you have to query them explicitly and then set correctly ListView headers.

First, in the query, specify them like this:

https://contoso.sharepoint.com/sites/hr/_api/web/Lists(guid'8556d320-3c1b-32e1-9fc6-e8501155516d')/items?$select=Title,Mentor/FirstName,Mentor/LastName&$expand=Mentor

(Suppose that contoso is your tenant name and Mentor the person field)

Then in your viewField props, you have to refer to your person field like this:

const viewFields: IViewField[] = [
      {
        name: 'Id',
        displayName: 'ID',
        maxWidth: 40,
        sorting: true,
        isResizable: true
      },
      {
        name: 'Title',
        linkPropertyName: 'Title',
        maxWidth: 40,
        sorting: true,
        isResizable: true
      },
      {
        name: 'Mentor.FirstName',
        displayName: 'Mentor Name',
        isResizable: true
      },
      ,
      {
        name: 'Mentor.LastName',
        displayName: 'Mentor Last Name',
        isResizable: true
      }
    ];

If you wish to have only one field, you can refer to the Mentor field and then override its render through the IViewField.render method.

Hope that it helps.

@joelfmrodrigues
Copy link
Collaborator

Closing as asnwered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants