After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 112060 - Sorting By Multiple columns should be supported
Sorting By Multiple columns should be supported
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.2.x
Other Linux
: Normal enhancement
: Medium API
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2003-05-02 10:02 UTC by Martyn Russell
Modified: 2014-08-03 20:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martyn Russell 2003-05-02 10:02:25 UTC
A customer has pointed out a feature which Microsoft Outlook has which the
GtkTreeView doesnt (it is also available in Excel using their sorting dialog).

If in Outlook I want to sort by two columns, I can click to sort by the
first column as normal, and then holding down SHIFT, I can click on another
column.  This will primarily sort by the first column clicked and then
subsequently by the second column header clicked.

Also, looking over the API for the GtkTreeView, there seems to be no way to
do this programatically either, sorting by ONE column alone seems to be the
only options (besides writing a sorting algorithm myself and updating
column headers manually).

I think there needs to be an API to set multiple columns to sort by, for
example:

  gtk_tree_view_set_column_sort_order(mytreeview,3,1,2,-1);

The -1 could finish the list of columns.
The actual column sort order (i.e. Ascending or Descending) could be
obtained from the current API calls (i.e.
gtk_tree_view_column_get_sort_order()).
Comment 1 Matthias Clasen 2003-05-06 08:55:32 UTC
If we implement this, we should make sure to avoid the problem I just 
noted with the Outlook implementation: It doesn't show visually which 
sort column is the more relevant one, leaving you confused about 
wether you're sorting "first by name, then by date" or "first by date, 
then by name".
Comment 2 Martyn Russell 2003-05-06 09:22:38 UTC
This is true!

Would you agree that the FIRST, and MOST important column should be
made obvious and the others should not?  For example, a particular
icon above the primary column and another icon to mark all others
(secondary, tertiary, etc).
Comment 3 Matthias Clasen 2003-05-07 07:16:03 UTC
I was thinking of some kind of double arrow, like <<. Unfortunately 
that doesn't scale to more than two or three columns. By the way, 
would shift clicking prepend a new sort column or append it. If it 
appends, then the approach of marking the primary column specially 
might look a bit awkward: you click on the date column, and the name


column changes visually (because it was the sole sort column before, 
and now is the primary one...). Don't know if that would be a real 
problem.
Comment 4 Martyn Russell 2003-05-07 07:43:26 UTC
I see your point about appending and prepending, and this would
acheive quite a flexibility, but I was thinking more along the lines
of simplicity to begin with.

If the user is unhappy with their sorting, then they can start again.
 This way ONLY having one method of ordering the sort.  Each click
(with the shift) would append the sort order (making the first click
the primary sort column).  

But if it is just as easy to implement, then perhaps there could be a
Ctrl+Shift+Click to prepend?

It has also occured to me, if the user has 4 columns ordered, and they
want to remove one of them, should there be a method of doing that or
should they have to start again?  For example, if columns 3, 1, 5 and
7 are sorted (in that order) and they want to remove column 5 from the
sort, should they be able to Shift+Click the column header again to
remove it?

I would like to see all these if possible (appending, prepending, and
removing the selected header to/from the sort).
Comment 5 Matthias Clasen 2003-05-08 10:30:59 UTC
No, you misunderstood me. I think have all of these is far too 
complicated. Thinking about the typical use case, additional sort 
columns should be appended, because you would typically start sorting 
by the most important criterion, find the list segment which interests 
you (e.g. all users with name "Frank"), then recognize that you need 
to "drill down" further (e.g. sort the Franks by age).




One thing which would add a lot of power (but which don't remember 
ever seeing in a treeview) would be the ability to sort only a 
selected region (e.g. assume you sorted by name, and found all users 
whose names start with "F", now you want to sort them by age, keeping 
them together as a block, but mixing the Franks and the Frederics).
Comment 6 Kristian Rietveld 2003-05-22 23:05:14 UTC
The TreeView sortable interface wasn't really designed for this IIRC.
It might need some refactoring if we want to get this working. I don't
think we are going to have time for 2.4.

Putting on future for now.
Comment 7 gbz 2005-04-11 12:48:34 UTC
Why not begin with introducing this feature in the API, and worry about the gui
later? After all, not all treeviews even have the column headers visible,
nevertheless they use sorting.
Comment 8 Amol 2008-05-28 05:17:26 UTC
(In reply to comment #0)

> I think there needs to be an API to set multiple columns to sort by, for
> example:
> 
>   gtk_tree_view_set_column_sort_order(mytreeview,3,1,2,-1);
> 
> The -1 could finish the list of columns.

should this api be added GtkTreeSortable interface or GtkTreeView?
TreeModels like GtkListstore or GtkTreeStore will implement this accordingly.
I don't see anyone except GtkTreeView might be using this but if some other widget 
wants this feature it may get it through GtkTreeModels.
what is current status of this bug? 




Comment 9 Matthias Clasen 2014-08-03 20:40:26 UTC
closing old bugs