How can I sort my table that is grouped by one field. I want it sorted by a second field and then a 3'rd field.

Like this:

Group: Harvest 2008

Type Item
------------
Corn Rye
Corn Wheat
Fruit Apples
Fruit Bananas
Fruit Oranges

So first the field 'Type' is sorted and then the field 'Item' is sorted (under Type occurrences).

Is this possible with the existing Views2?

Or is it necessary with another contrib module - or possible at all?

Thanks for all your help.

Morten E

Comments

MBroberg’s picture

That would be great but so far the answer seems to be "not currently possible."

I did do something with "group by" to get extra fields in the headers.
See comment at
http://drupal.org/node/673982#comment-2504410

By using node references I was able to get more information into the view.
For now I think this is the limit of what is possible.

esmerel’s picture

Status: Active » Closed (fixed)

No activity for 6 months, comment 1 appears to have a good suggestion to resolve issue.

MBroberg’s picture

Category: support » feature
Status: Closed (fixed) » Active

I don't think my suggestion really resolves the issue. It is just a temporary way to get more than one field in a "group by." What is really needed is multiple "group by" levels, similar to "sort criteria" where a person can select a field to group by and then another field under that, and so on.

For example, in a regular view you can group by only one field such as state:

California
--restaurant, address
--restaurant, address
--restaurant, address
--restaurant, address

Arizona
--restaurant, address
--restaurant, address
--restaurant, address
--restaurant, address

With my suggestion in #1 you can still only group by one field, but put more details into that field

San Diego, California
--restaurant, address
--restaurant, address

Los Angeles, California
--restaurant, address
--restaurant, address
--restaurant, address

What is really needed is more like:

California
-Sandiego
---restaurant, address
---restaurant, address
-Los Angeles
---restaurant, address
---restaurant, address

Arizona
-Phoenix
---restaurant, address
---restaurant, address

As far as I can tell that is still not currently possible and still requested frequently by many Drupal users.
We need multiple "group by" levels.

dawehner’s picture

Status: Active » Postponed

This issue is closed because there was no activity/no active patch etc. in the last 6 months.

As you see this is a really feature request. Please don't disagree with the maintainer of views

merlinofchaos’s picture

Category: feature » task
Status: Postponed » Active

Multi level grouping is something I would like but have never tackled. Moving to active task.

arx-e’s picture

+subscribing

I have been searching for a few hours for a way to list in a view some hotels grouped by prefecture grouped by region but I have found no way to do it yet.
Any workarounds/suggestions known for the time being?

dawehner’s picture

There is already some work buy really just some work on #477338: Multiple group: group by more than one field

WillHall’s picture

Faced a similar issue recently - let me know if this helps.

http://mrtheme.com/cms/drupal/drupal-7-building-tree-like-displays-in-vi...

That is a little out of date, in the end this was the solution for me.

function aahax_views_pre_execute(&$view){
  if ($view->name == 'videos')
  {
    if($view->current_display == 'block_1') {
      //drupal_set_message($view->current_display);
      $view->build_info['query']->groupBy('field_data_field_category_field_category_value');
      $view->build_info['query']->groupBy('field_data_field_subcategory_field_subcategory_value');
      //drupal_set_message($view->build_info['query']);
    }
  }
  if ($view->name == 'technical')
  {
    if($view->current_display == 'block_1') {
      $view->build_info['query']->groupBy('field_data_field_category_field_category_value');
      $view->build_info['query']->groupBy('field_data_field_subcategory_field_subcategory_value');
    }
  }
}
arx-e’s picture

Thank you for your replies.
Will, it seems you have a solution but... even if I was using D7 (which I am presently not), it would take me at least 2 days with dull weather and clear mind to get to grips with it... I have never gone so deep with Drupal till now.
Since my level 0 categories are finite and not exceeding a dozen, I think that I will set up this page with multiple predefined views and viewfield.

MustangGB’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)