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 from the DetailList rendering.
I have a code that render the list content and columns using pnp ListView component. But this code has harcoded 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.