Hi,
I understand that in SS3, you can extend ModelAdmin, and provide the getExportFields() function to supply the export columns for the "export to csv" functionality.
What if I am not extending ModelAdmin, but using the default Security tab to try to export the Member database?
Currently I am using a custom "MyMemberExtension" dataextension to extend the default Member dataobject, and dataextension doesn't seem to expose functions for modifying the "export to csv" functionality, short of providing the entire Member dataobject as columns in summary_fields to get it to work.
Is it possible for the "MyMemberExtension" to access the GridField of the Security page in the cms?
[Solution]
Decorate the SecurityAdmin class:
_config.php add
Object::add_extension('SecurityAdmin', 'MySecurityAdminExtension');
MySecurityAdminExtension.php:
class MySecurityAdminExtension extends Extension {
function updateEditForm(&$form) {
$gridField = $form->Fields()->fieldByName('Root.Users.Members');
if ($gridField) {
$gridField->getConfig()->getComponentByType('GridFieldExportButton')->setExportColumns( array(
'YourFieldSource' => 'Your Field Label',
'FirstName' => 'First Name',
'Surname' => 'Surname',
'Email' => 'Email',
.....
));
}
}
}
[/Solution]