0

I have encountered a situation where I need to display a Dropdown and want the options to dynamically fetch from an API and load on clicking the caret (maybe show a loader by the time the API response comes through). The experience I am looking for is something in the following lines -

enter image description here

Loading (fetching options from API)

enter image description here

Display options after successful response

The documentation didn't give any API surface through which this can be possible. Is it possible to achieve this with the current APIs that are in place for this control component?

Kaustabh Kakoty
  • 87
  • 3
  • 15

1 Answers1

0

Good point to start is to use BasePicker Component from Pickers.

import { BasePicker } from 'office-ui-fabric-react/lib/Pickers'

Inside BasePicker you have a methods which you can use to make a "lazy" behavior. For example, when you click on component then make a call to API and populate items list.

What is inside BasePicker take a look here or from official documentation.

Codepen example

Marko Savic
  • 2,159
  • 2
  • 14
  • 27