fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

People Picker question

Open gabrielruss opened this issue 9 years ago • 3 comments

I am working on adding a people picker component and I was wondering if there is an "official" or "supported" way to handle searching for the users. I have seen examples where you send the text input to a REST call that searches the user profile service. On the http://dev.office.com/fabric#/components/peoplepicker page, the example only shows pulling in example data from a "people" import so I wasn't sure what you guys typically use in a real world environment to pull in and filter the user info.

Any help would be greatly appreciated.

gabrielruss avatar Feb 03 '17 16:02 gabrielruss

@gabrielruss why would you not consider the REST call model? I do the following;

class MyComponent extends React.Component {
 
 //this calls my backend api to get the list of users the backend api
 //returns a json with an array of objects that is [{primaryText: 'Gabe Russ', secondaryText: '@gabrielruss'}, {primaryText: ......}]  
 _onAddressFilterChanged (filterText, currentSelected, limitResults?) {
      return axios.get('/filterusers', params: {q: filterText}})
          .then( (results) => Promise.resolve(results))
          .catch( (error) => Promise.reject(error) )
  }

  static suggestionProps = {
    suggestionsHeaderText: 'Suggested People',
    noResultsFoundText: 'No results found',
    loadingText: 'Loading'
  }

  render () {
    return (
      <CompactPeoplePicker
        onResolveSuggestions={this._onAddressFilterChanged}
        getTextFromItem={(persona: IPersonaProps) => persona.primaryText}
        pickerSuggestionsProps={this.suggestionProps}
       />)
   }

}

panigrah avatar Mar 07 '17 14:03 panigrah

I moved forward with just using a normal REST call to the site's user list. I was just wanting to see if others had any different approaches.

gabrielruss avatar Mar 07 '17 14:03 gabrielruss

I am using people picker in SharePoint Extension, and couldn't find a way to allow the user to enter emailaddress say [email protected]

PhaniKumarAddala avatar Nov 23 '17 00:11 PhaniKumarAddala