Recently I had to create a jump menu in views, listing all terms in a vocabullary. Terms were of maximum 2 levels.
This is how I did it:
- Create a view with “Jump Menu” style
- Add Term Name & Tid fields
- Add Taxonomy Term:parent relationship
- Add one more Taxonomy:Term Name field, using the relationship just created. Choose this field as grouping field in Jump menu settings.
- Add a filter Taxonomy:Term Name using the same relationship, with the operator “Is not equal to”. Keep the operator value empty.
That will create a jump menu with first level terms as <optgroup> items.