Forum Discussion

Americo Perez's avatar
Americo Perez
Iron Contributor
Jun 04, 2019

How to populate the dropdown with list names

Hi,

 am trying to create a dropdown in the property panel of a webpart with SPFx and I found this tutorial: 

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/use-cascading-dropdowns-in-web-part-properties#create-new-project

 

The problem with the sample is that is is using static data and I would like to know how to fetch the list names dynamically.

 

How can I do that? 

 

Best  regards

Americo

1 Reply

  • Hi @America
    You can load all lists from current site or specific site collection by calling SharePoint REST API using SPHttpClient class of SPFx or you can use fluent APIs of @PnP which is great wrapper around SharePoint APIs.

    You can more details about SPHtppClient class here

    https://docs.microsoft.com/en-us/javascript/api/sp-http/sphttpclient?view=sp-typescript-latest

Resources