Skip to main content

Remove glazedlists in favor of JXTable: JXTable can't sort multiple columns

9 replies [Last post]
ge0ffrey
Offline
Joined: 2005-11-16
Points: 0

We use glazedlists in combination with JXTable, but since swingx is become more alive and because the integration cost is high (we're still stuck with swingx 0.9.3 because of this), we've been thinking about dumping glazedlists and relying solely on JXTable for all those wonderfull features.

The problem is, there's 1 regression of JXTable-solo VS glazedlists-JXTable
https://swingx.dev.java.net/issues/show_bug.cgi?id=35
JXTable can't sort on multiple columns.

In that use case, if the user clicks on multiple columns, the first column gets a "arrow up" icon and the second (and third etc) column gets a smaller "arrow up" icon, to indicate that it's first sorted on the first clicked column and then on the next column. Double clicking on a column header resets the sorting and makes it sort only on that column.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11
Points: 0

btw, just to clarify: J/X/Table _does_ sort by multiple columns - it just don't give a visual feedback. The default are 3 sortkeys, the first is the primary and that's set on click.

Cheers
Jeanette

kleopatra
Offline
Joined: 2003-06-11
Points: 0

not trivially solvable for several reasons

- difficult to add custom icons without interfering with LAF specifics
- difficult to hook-into/augment the mouse handler registered by the LAF
- the user interaction is non-standard, too many options?

GlazedLists can do because they take over completely: as far the JTable/SomeTableUI is concerned that table is unsorted.

A bit pessimistic, but not entirely :-)

CU
Jeanette

belion
Offline
Joined: 2007-01-19
Points: 0

Hi,

just some reanimation of this issue. I need this in my actual project. But i don't want to use GlazedLists. After some searching i found this class, which works very well for me.

http://tips4java.wordpress.com/2010/08/29/multisort-table-header-cell-re...

Maybe this is an option for JXTable...

david_hall
Offline
Joined: 2003-06-12
Points: 0

One thing I've done with sorted tables is not use icons -- there are UML characters for up & down pointing triangles. The OP can change the label in the table header to include the correct UML character fairly easily. I haven't tried this (but it just may work), but if the table headers contain html wrapped around the UML, OP may be able to get triangles in different sizes.

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Dave,

interesting idea, never thought of that :-) Just ...

- can't really imagine how that looks: having the LAF icon plus the char in the text
- doesn't solve the tricky part of easily loosing LAF specific visuals (like rollover, f.i.) Remember that we had to do some dancing before delegating to core sorting

Happy holiday!
Jeanette

david_hall
Offline
Joined: 2003-06-12
Points: 0

it's an easy (if not necessarily pretty) way to add the indicators to the second and subsequent sort columns. Most of the time, the icon is fairly close to a UML character of one kind or another, so you can get the look so that it doesn't clash too badly. OP could try leaving the built-in indicator on the primary sort field and manipulate the labels on the secondary fields.

I've also used this trick to create a combo-like control consisting of a button & menu (the button contains a down arrow, clicking on the button brings up a menu) when I was needing something that doesn't transfer the input focus (I had an editor and the combo-ish was used to insert special characters)

kleopatra
Offline
Joined: 2003-06-11
Points: 0

will certainly try it :-)

Thanks
Jeanette

kleopatra
Offline
Joined: 2003-06-11
Points: 0

> will certainly try it :-)
>

finally made it - wonders take a bit longer ;-)

It's an example in the JXTableVisualCheck, and true: not necessarily pretty. The parts involved:

- a custom TableColumnExt which manipulates the headerValue if sorted
- a custom ColumnFactory which creates the custom column type
- a RowSorterListener which updates the column's sort marker on receiving a sortOrderChanged

not sure I want to commit to that, not even as an option - thoughts?

Thanks
Jeanette

david_hall
Offline
Joined: 2003-06-12
Points: 0

makes sense not to - but worth keeping around somewhere (incubator?) as a last-resort kludge