Forum Discussion
Americo Perez
May 31, 2019Iron Contributor
Render list columns dynamically with UI Fabric DetailList component?
Hi, I was asked to render a list with UI Fabric DetailList component but dynamically, thats mean that if the user adds or removes columns in the source list these columns should be shown or removed ...
Thomas Berman
Jun 12, 2019Iron Contributor
You're going to want to grab the list columns.
You have a few options on how to logically get the right columns - depends on your solution. Some of the options are:
- Grab the list content type that has the columns you need
- Grab the list view that has the columns you need
- Grab ALL columns and filter out the system generated ones like modified/created etc
How you choose to get the correct columns is totally up to you depending on your situation). Once you've grabbed and filtered the fields you need, build your IViewField array out of those returned values and their properties.
You can easily grab the fields with PnPJS.