Skip to main content

JXTreeTable sorting

11 replies [Last post]
vijirajan
Offline
Joined: 2003-07-21
Points: 0

Hi,

How do I enable column sorting in a JXTreeTable?

Thanks,
Rajan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bubu1979
Offline
Joined: 2006-03-07
Points: 0

Hi Eclipse does it in the problems pane, its a sorting by level thing,

vijirajan
Offline
Joined: 2003-07-21
Points: 0

In my case, sorting the treetable means sorting the leaf nodes under each parent.

-Rajan.

siva
Offline
Joined: 2003-07-15
Points: 0

Yes, that's what I would expect too. Sorting a tree means, recursively sorting the children. This would retain the tree structure and yet provide sorting.

allquixotic
Offline
Joined: 2005-05-31
Points: 0

In my case, "Sorting" (the way my users describe it) would involve re-arranging the hierarchy of the nodes O_o For example, let's say I originally have it organized as such:
[code]

Tree Column | Data Column 1 | Data Column 2
__________________________________________________________
[-]ID
|
[-]Sub-Branch |
| |
|--Leaf 1 | "Some Data" | $3.26
[/code]
So I have a flat table (no relationships, single-table only) in a JDBC:ODBC DataTable, with a JDBCDataSetProvider bound to the DataTable. The user wants to be able to re-arrange it so that any arbitrary field(s) can restructure the hierarchy so that you can "view" the data in any desired way. HOW might I do that?! Remember that the data is flat, and both the end-user and I understand that, so it's a matter of re-creating the tree and re-associating the nodes, based on which column(s) the user chooses to sort by. Those columns would also be removed from the "table" part of the TreeTable, as their values would reside in the tree:

[code]
Tree Column | Data Column 1 | Data Column 2
__________________________________________________________

[-]ID: 1
|
[-]Program: MRLO|
| |
|--Draft 1 | "Some Data" | $3.26
| | |
|--Draft 5 | "Some Data" | $3.26
| | |
|--Approved | "Joe Smith" | $30000.26

[-]ID: 3
|
[-]Program: DESS|
| |
|--Draft 1 | "Some Data" | $3.26
| |
[-]Program: MRLO| |
| | |
|--Draft 1 | "Heh" | $3.26
| | |
|--Draft 2 | "Wow" | $3.26

[/code]

[b]WOULD BECOME[/b] (please bear with me):

[code]
Tree Column | Data Column 1 | Data Column 2
__________________________________________________________

[-]Program: MRLO
|
[-]ID: 1 |
| |
|--Draft 1 | "Some Data" | $3.26
| | |
|--Draft 5 | "Some Data" | $3.26
| | |
|--Approved | "Joe Smith" | $30000.26
[-]ID: 3 |
| | |
|--Draft 1 | "Heh" | $3.26
| | |
|--Draft 2 | "Wow" | $3.26

[-]Program: DESS
|
[-]ID: 3 |
| |
|--Draft 1 | "Some Data" | $3.26
[/code]

Given the source data is a flat table containing:

[code]
ID | Program Name| Type | Data 1 |Data 2
-----------------------------------------------------
1 | MRLO | Draft 1| "Some Data" | $3.26
1 | MRLO | Draft 5| "Some Data" | $3.26
1 | MRLO |Approved| "Some Data" | $30000.26
3 | DESS |Draft 1 | "Some Data" | $3.26
3 | MRLO |Draft 1 | "Heh" | $3.26
3 | MRLO |Draft 2 | "Wow" | $3.26
[/code]

Think of an analogy: in the MS Office Excel and OpenOffice.Org Calc, you can take a multi-row, multi-column chunk of data and "Sort by" several rows and columns at once: "By dollar amount, then by program name", or "By program name, then by dollar amount" - whichever the user chooses. Calc/Excel can drill down three levels of sorting. If you expanded every branch on my tree, you would "get" exactly that type of Excel-style flat table sort, [b]pivoting[/b] on any number or type of key, plus several extra "rows" in the TreeTable for each branch (with blank data across the rest of the columns).

This seems like a pretty common approach for displaying data... take a flat file and sort it. Has JDNC made any progress toward making it easier for developers to do this, since the last date of posting in this thread, Jan 5 2005?

Regards,
Sean

Kleopatra

jdnc-interest@javadesktop.org wrote:

> Has JDNC made any progress toward making it easier
> for developers to do this, since the last date of
> posting in this thread, Jan 5 2005?

unfortunately the answer is no - sorting/filtering in treetable is still
not well defined and leads to unpredictably weird results...

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

rameshgupta
Offline
Joined: 2004-06-04
Points: 0

> > Has JDNC made any progress toward making it easier
> > for developers to do this, since the last date of
> > posting in this thread, Jan 5 2005?
>
> unfortunately the answer is no - sorting/filtering in
> treetable is still not well defined and leads to
> unpredictably weird results...

If nodes are sorted within their parent node, the results are both well-defined and predictable ;-)

http://www.javadesktop.org/forums/thread.jspa?forumID=53&threadID=11449&...

Ramesh

Kleopatra

Hi Ramesh,

>>
>>unfortunately the answer is no - sorting/filtering in
>>treetable is still not well defined and leads to
>>unpredictably weird results...
>
>
> If nodes are sorted within their parent node,
> the results are both well-defined and predictable ;-)

yeah - but that's not implemented

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

bino_george
Offline
Joined: 2003-06-16
Points: 0

Hi Rajan,

> How do I enable column sorting in a JXTreeTable?

Even though JXTreeTable extends JXTable, JXTreeTable
overrides a lot of the sorting related methods to be
no-ops. So at the moment it is not possible. You could
try to extend JXTreeTable and implement similar
functionality to JXTable, but it wont be easy and
I dont know if it is doable. Ramesh may have some
thoughts on this.

Regards,
Bino.

bino_george
Offline
Joined: 2003-06-16
Points: 0

Just to follow up on this. What does it mean to
sort a TreeTable anyway ? Would you sort
within each level ? I have not seen any TreeTable
type component that does sorting, they all tend to
flatten to a table when you sort.

Bino.

awf999
Offline
Joined: 2003-07-06
Points: 0

I have had to implement TreeTables in VB6 that allowed for sorting in the past. I sorted the TreeTable as if it was just a Table.

programmer_1
Offline
Joined: 2011-10-26
Points: 0

hi,

I am new to this forum. I have problem in sorting jxtreetable. please post the code for sorting JXtreetable