Can a reusable SPFX be built to use it on either Contact list or Company list ?

Copper Contributor

We are trying to build a reusable custom webpart, 
1. Lets consider we have a List "Contact" which contains the field name, Address, Contact Number.
2. A list named "Company" which contains the field name Company name, Company Address, Pin code.
3. The data type of the columns in both the lists are the same.
4. We want to build a webpart which displays the fields in a certain format or UI.
5. Idea is to build one webpart and have custom properties (List Name, Column A, Column B, COlumn C), 
    List Name is either Contact / Company
    Column A is either Name / Company Name
    Column B is either Address / Company Address
    Column C is either Contact Number / Pincode

1 Reply

Hi @Samridhi_Gupta,


you could use the PropertyFieldListPicker in your property pane to select the list 

https://pnp.github.io/sp-dev-fx-property-controls/controls/PropertyFieldListPicker/
and then three instances of the PropertyFieldColumnPicker
https://pnp.github.io/sp-dev-fx-property-controls/controls/PropertyFieldColumnPicker/
to select your three fields from the list.

Now you can use the listname/id and the three fieldnames as parameters in your webpart.

Best Regards,
Sven