posted 22 years ago
Hello All,
I would like to know if anyone has any full working examples of sorting a jtable on multiple columns. I have the following data items in a table.
When the user clicks on the market column,
the results should be sorted by market, code,sequence like..
market media code sequence
BF TV 7 1
CA LM 2 1
CA LM 5 1
CA LM 5 2
HT TV 1 1
HT TV 1 2
HT TV 1 3
NY OD 3 1
if the user sorts on media, the code should be ordered by media, code, sequence..
market media code sequence
CA LM 2 1
CA LM 5 1
CA LM 5 2
NY OD 3 1
BF TV 7 1
HT TV 1 1
HT TV 1 2
HT TV 1 3
The problem is that I have multiple rows in the table that relate to each other and therfore need to keep them together on any sort that is done.
The rows need to be always sorted first by clicked column and then by code and sequence.
I am using the sort logic from this site as a starter..
http://www2.gol.com/users/tame/swing/examples/JTableExamples5.html
It only allows sorting on one column.
Any help would be appreciated
John.