Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Export Member columns in Security tab

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

Page: 1
Go to End
Author Topic: 353 Views
  • cwchong
    Avatar
    Community Member
    13 Posts

    Export Member columns in Security tab Link to this post

    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]

    353 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.