I'm trying to create a doc export for a view where I need the output to be grouped by a certain field. When I click the option under the Advanced Settings it allows me to check a box labeled "Group by" but nothing else. This checkbox doesn't seem to do anything. Is this an unfinished feature or is there just something wrong with my view?

Thanks

Comments

steven jones’s picture

Status: Active » Closed (works as designed)

Grouping is not supported in views data export I'm afraid.

deggertsen’s picture

Version: 6.x-3.0-beta4 » 6.x-3.x-dev
Category: support » feature
Status: Closed (works as designed) » Active

Could I make this a feature request then?

DeFr’s picture

Status: Active » Needs review
StatusFileSize
new1.46 KB

Supporting result grouping is actually kinda easy, everything suddenly starts to work when views_data_export_plugin_style_export::options_form calls it's parent options_form as it should. I'm attaching a patch that does that. With it, $title is now correctly passed down to the templates as their javadoc implies it should.

The tricky part might be to decide how each of the built in templates should be updated to include those grouping informations. It would be fairly straightforward to add a around the XML tag in the XML output, and a new row with an appropriate colspan can be added to the xml and doc output, but I'm not sure what would be a fitting group representation for the txt and csv case. Do you have any preference about that ?

jvdurme’s picture

Hello,

I would like to see grouping in xls and cvs format, do you think this is possible?
For these formats, it would be cool if we can choose the separator like a comma or colon or similar.
Then the values of the grouping field are separated by the custom separator.

No idea how easy or difficult this is. You know this better than me. ;)

Thanks in advance!

trillex’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Ditto, as it stands, most tools that import csv files require the entire content of a field in one line. For example, I'm trying to pull out a list of ordered products through Ubercart. I can set it up just fine with grouping in the regular view but not with the csv export. Did any of you ever find another way to do this?

star-szr’s picture

StatusFileSize
new566 bytes

Rerolled patch for 7.x-3.x-dev. Seems to work fine for grouping.

star-szr’s picture

Actually it might just be changing the sorting, I don't have a good test case for this right now.

Zippy’s picture

Hi,

for me the patch isn't working as expected. I want to group values just the same way I did in my normal view, but I can't get the grouping caption into the exported documents. So the only thing I get after patching the module is a pull down menu to select entries for grouping. Maybe I got these problems because of the used field collections...

aniebel’s picture

I concur that the patch is only providing the option in the XML settings but not grouping the XML. Here's what I am trying to do if this helps:
I have a directory of businesses with business names. I built a View pulling all published businesses and am displaying business name and the business category taxonomy term. I would like to nest all business name elements within their term element so...

<root>
     <auto mechanics>
          <profile>Business AA</profile>
          <profile>Business AB</profile>
          <profile>Business AC</profile>
     </auto mechanics>
     <carpenters>
          <profile>Business BA</profile>
          <profile>Business BB</profile>
          <profile>Business BC</profile>
     </carpenters>
</root>
orbistertius’s picture

I was looking for this feature as well, specially in XML this is a normal use case.
Would be nice to see 2 kinds of grouping:
1. by a field (if you are building a views with entities like #9)
2. by grouping fields (like in the table view mode settings where you can add fields in the columns of an other field)
Tried to find a workarround for 2, but if you rewrite a field output to group fields the XML markups are changed to HTML.
Thanks in advance.

steven jones’s picture

Status: Needs review » Needs work
StatusFileSize
new3.41 KB

Here's a go a making the grouping working with XML

steven jones’s picture

Status: Needs work » Needs review

Let's get the testbot to look at this.

steven jones’s picture

Status: Needs review » Needs work
fernando vesga’s picture

Hi

I've been using this patch, and i needed to make some changes in the views-data-export-xml-body.tpl.php file.
When i export an xml to a path, and try to parse it in and external php page with simplexml_load_file function, allways showme an error.

I mean, this was my previous xml export:

<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
  <category:-pdf>
  <node>
    <title>.....</title>
    ....
  </node>
  </category:-pdf>
</nodes>

The error was the : before my gruoping field label, so i delete the label, getting this xml:

<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
  <pdf>
  <node>
    <title>.....</title>
    ....
  </node>
  </pdf>
</nodes>

But if i want to use this xml on and external php file and show nodes group by my category, i dont know how to count categories, i can't do this $cats = count($xml->category); because there is no category tag or grouping tag, every one of these have different names.

What i did?

in views-data-export-xml-body.tpl.php i added a group tag with the title of the group as an attribute, so then i can execute $cats = count($xml->group); giving me the exact numbers groups in my xml

<?php if (!empty($title)): ?>
  <group name="<?php print $title; ?>">
<?php endif; ?>
<?php foreach ($themed_rows as $count => $row): ?>
  <<?php print $item_node; ?>>
<?php foreach ($row as $field => $content): ?>
    <<?php print $xml_tag[$field]; ?>><?php print $content; ?></<?php print $xml_tag[$field]; ?>>
<?php endforeach; ?>
  </<?php print $item_node; ?>>
<?php endforeach; ?>
<?php if (!empty($title)): ?>
</group>
<?php endif; ?>

I don't know if this is useful, but for me it was. I must say i'm a pretty coder noob, so maybe there is a shorter way to achieve this without hacking the .tpl

Drupa1ish’s picture

Issue summary: View changes

An workaround is https://www.drupal.org/project/views_field_view and inside embedded view use grouping

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new4.15 KB

Attached patch implements grouping for XLS files in addition to the previous changes.

Status: Needs review » Needs work

The last submitted patch, 16: views_data_export-grouping-1187712-16.patch, failed testing.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new3.92 KB
new708 bytes

I created the patch from the Drupal root instead of the module directory. Attached patch is created from the correct directory.

misterpo’s picture

Hello all,

I am running Views Data Export 7.x-3.x-dev patched with code given in #18 on a Drupal 7 web site.

Only the first grouping field work.

As soon as I add a second grouping field, my view becomes empty.

Any idea ?

misterpo’s picture

Hi,

Any news about this multiple fields grouping issue ?

Thx in advance.

stomusic’s picture

Last patch have problems with batch export. One group title sometimes multiple print

delacosta456’s picture

Hi
and many thanks for this nice Grouping patch that worked nicely for me.

However is there possibility to have a kind of aggregation on that grouping (like sum count) so that we me have exported group with intermediate summary ?

Also .. if XLS with septate cell format ( provided by the module https://www.drupal.org/project/views_data_export_phpexcel) the grouping functionalities are lost
thanks

It's the same thing when applying this patch https://www.drupal.org/node/1269994 to have a Proper XLS exports using PHPExcel (After applying that patch it is not possible to apply the grouping patch)

delacosta456’s picture

hi .. please can we have an intermediate sum row of each group ?

thanks

ckl’s picture

#18 work for me
thank you idebr

prashant.c’s picture

Status: Needs review » Reviewed & tested by the community

#18 worked for me.

@idebr thanks for your efforts. You saved my day. It should be committed.

markusd1984’s picture

Yeah grouping works as in the results are grouped however when a table is used with grouping that the content of that field e.g. title is not included in the grouped output.

E.g. a manual setting or better a check when table>grouping is used to then output that field in the first column.

proweb.ua’s picture

#18
Grouping field: id

error on line 3 at column 14: Failed to parse QName 'object_id:'

<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <id:-ER-N-V15-U>
  <object>
    <language_id>3</language_id>
...
steven jones’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)