Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » ModelAdmin & CSV Export issue?

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 4425 Views
  • ciaranhickey
    Avatar
    Community Member
    17 Posts

    ModelAdmin & CSV Export issue? Link to this post

    Hi,

    I've searched the forums/documentation and can't find any info on this...

    With the ModelAdmin export to CSV function, is it possible to export more than just the summary fields that are displayed?

    When my client is using the system it is only sufficient for them to see 4 or 5 summary fields of the DataObject but would like to be able to export ALL fields of the DataObject to CSV. I've had a look at http://doc.silverstripe.org/tablelistfield but don't know how to tie this into the default CSV Export button in modeladmin, or if I need to create a custom CsvQuery?

    Any help would be great!

    Thanks,
    Ciaran

  • Simkim
    Avatar
    Community Member
    9 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Hi,

    Did you find any solution? I'm stuck with the same problem...

    Thank you very much

    Mercedes

  • ciaranhickey
    Avatar
    Community Member
    17 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Hi,
    I never got it solved unfortunately

    If you do manage to find a solution please post on the forum (if you get time), and I'll do the same.

    Regards,
    Ciarán

  • Simkim
    Avatar
    Community Member
    9 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Hi,

    I have found a solution. It's not the best, but it works...

    In the DataObject of the ModelAdmin I have defined the variable $summary_fields with all the fields I need in my csv file.

    public static $summary_fields = array('var1','var2', 'var3');

    I have also added a javascript file where I search the checkboxes in the search form (which are the same as in the summary_fields variable, and I change the state from checked to not checked. When the system creates the .CSV file, it doesn't matter if the checkbox is marked or not, it will include all fields in the CSV.

    document.getElementById('id_from_the checkbox_in_the_search_form').checked = false;

    I hope this will serve you.

    Best regards,

    Mercedes

  • ciaranhickey
    Avatar
    Community Member
    17 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Great, I'll give this a go!

    Thanks a lot

    Regards,
    Ciarán

  • camfindlay
    Avatar
    Forum Moderator
    148 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Having the exact same requirement from a client too, anyone found a good solution to this?

  • EzraNaj
    Avatar
    Community Member
    11 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Silverstripe crashes when I run CSV export on an empty result.
    Is this a core issue?
    Does anybody have an idea how to fix this?

  • James Bolitho
    Avatar
    Community Member
    33 Posts

    Re: ModelAdmin & CSV Export issue? Link to this post

    Hi,

    I know this is an old-ish thread but wondered if someone had come up with a fix for this and wouldn't mind sharing a bit of example code?

    Cheers,

    Jim

    4425 Views
Page: 1 2
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.