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.

All other Modules /

Discuss all other Modules here.

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

ModelAdmin & CSV Export issue?


Go to End
Reply


16 Posts   4827 Views

Avatar
ciaranhickey

Community Member, 17 Posts

14 May 2010 at 10:07pm

Edited: 14/05/2010 10:08pm

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 [url]http://doc.silverstripe.org/tablelistfield[/url] 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

Avatar
Simkim

Community Member, 9 Posts

13 July 2010 at 3:27am

Hi,

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

Thank you very much

Mercedes

Avatar
ciaranhickey

Community Member, 17 Posts

13 July 2010 at 5:05am

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

Avatar
Simkim

Community Member, 9 Posts

13 July 2010 at 7:55am

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

Avatar
ciaranhickey

Community Member, 17 Posts

13 July 2010 at 9:45pm

Great, I'll give this a go!

Thanks a lot :)

Regards,
Ciarán

Avatar
camfindlay

Forum Moderator, 210 Posts

4 August 2010 at 9:22pm

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

Avatar
EzraNaj

Community Member, 11 Posts

22 October 2010 at 7:44pm

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?

Avatar
James Bolitho

Community Member, 33 Posts

27 October 2011 at 5:17am

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

Go to Top