I have a large multi-page webform with multiple fieldgroups. Each fieldgroup contains 10 questions - each weighted 1 - 10. When exporting to a CSV file the questions are not in order of fieldgroup, weight. But, ordered by weight alone.

The order is determined by the order of node->webformcomponents. This is set during node_load at line 150'ish in webform.module:

  $result= db_query('SELECT * FROM {webform_component} WHERE nid = %d ORDER BY weight, name', $node->nid);

You can add the parent ID as a sort term and get the desired sorting (if your parents were created in the sort order you want)

  $result= db_query('SELECT * FROM {webform_component} WHERE nid = %d ORDER BY pid, weight, name', $node->nid);

My SQL writing skills are not up to the task of joining the pid's weight so that the sort will work properly. Hope this helps other's export problems.

Comments

bassplaya’s picture

I've been looking for this for a long time.
It works great, even in Drupal 4.7 Thanx !!

quicksketch’s picture

Status: Active » Closed (duplicate)

Thanks, we put this in from this issue (same solution): http://drupal.org/node/190193.