Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Export Member columns in Security tab


Go to End


2164 Views

Avatar
cwchong

Community Member, 13 Posts

22 May 2013 at 6:05am

Edited: 23/05/2013 8:11am

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]