silverstripe/sapphire — pull request #257 by halkyon (2012-03-23 04:14:32+00:00)
Title: GridFieldExportButton changes to support customisation of which fields to export

Added a new export_fields static on DataObject, works the same way as summary_fields, except that it's used by GridFieldExportButton primarily to determine which fields are set as columns in a CSV export. Can be extended on a DataExtension, using extraStatics like you would the summary_fields. If export_fields doesn't exist on the source data class, it fails over to the summary_fields, which is how GridFieldExportButton currently works.

Also modified the GridFieldExportButton to support has_one relations as fields, e.g. "Team.Title" to traverse to the related Team object and display the Title field in the CSV column. has_many and many_many are a bit harder, so not sure how to handle that in a nice way.

If this export_fields idea looks good, I'll write some unit tests to cover the export_fields changes.