Dynamic columns in GridField

Silverstripe Version: 4.3


Is it possible to add dynamic column data to a gridfield?

I have the DateObject “Participant” with some regular fields (firstname, lastname etc).

A DateObject “ParticipantGroup” would have a List of custom fields specific to that group.

Can I create a gridfield of Participants that shows that data (if available) alongside the regular fields? Setting the gridfield headers is easy but I didn’t manage to display the existing custom values the gridfield. Is there a way to achieve this?

You might need to be a bit more explicit about what you mean by “Dynamic Columns”? Do you mean:

  1. That you want to pre-define some extra columns that display dynamic (not in the DB data)? If so, you can add casted fields and methods to your DataObject's summary_fields: https://docs.silverstripe.org/en/4/developer_guides/model/data_types_and_casting/#casting
  2. You want to allow users to select which columns appear? If so, the GridFieldUserColumns component might help: GitHub - i-lateral/silverstripe-GridFieldAddOns: GridFieldAddOns is a collection of plugins for the Silverstripe GridField.
  3. Something else (if so, could you please provide some more details)?