|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
TreeTable: sorting leaf nodes via TableComparatorChooserHey James and Jesse,
I was thinking about the following case: You've setup a TreeTable with a default sorting for each depth via appropriate comparators returned by the TreeList.Format. Now suppose you'd want to change the sorting of the current leaf nodes based on "selected" column(s), e.g. you want to click on a column header and *resort the current leaf nodes only* according to the values of that column. Is that achievable right now? If yes, how? Thanks, Holger __________________________________________________________________________ Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele ausländische Netze zum gleichen Preis! https://produkte.web.de/webde_sms/sms --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: TreeTable: sorting leaf nodes via TableComparatorChooserOn Sun, May 10, 2009 at 4:26 AM, Holger Brands <hbrands@...> wrote:
You've setup a TreeTable with a default sorting Yeah, you'll need to create a TreeFormat whose Comparator knows about the TableFormat and the selected columns. Whenever you need to sort 'leaves only' it's necessary to differentiate between leaves and non-leaves. Therefore that sorting mode isn't really appropriate for "variable depth" trees like file browsers.
|
|
|
|
|
|
Re: TreeTable: sorting leaf nodes via TableComparatorChooser
Holger Brands wrote:
I've tried to accomplish this in the past without much luck. Ideally, I would like to sort the top level nodes based on the selected column sorting and then treat each subsequent level in the tree as a sort down to the leaf level. I wrote and have attached a sample application to try do this for a two level tree. In TradeTreeFormat, the getComparator returns a sortComparator object that stores the state information of the TableComparatorChooser for the given column. Right now it only sorts on the top level parent, but I think the solution extends to any tree depth whether parent, leaf, or something in between. @Override public Comparator<? extends Trade> getComparator(int depth) { if (tcc != null) { final List <SortCriterion> sortCriteria = new ArrayList<SortCriterion>(); final List <Integer> sortedColumns = tcc.getSortingColumns(); for (Integer column : sortedColumns) { sortCriteria.add(new SortCriterion(column, tcc.isColumnReverse(column))); } sortComparator.setCriteria(sortCriteria); return sortComparator; } return new SymbolComparator(); } Unfortunately, I keep running into a problem where at times, when a new item is inserted into the flat list, TreeList will fail to insert it into the correct, sorted parent which results in "duplicate" parent nodes being visible until the column is manually re-sorted. If you run the attached treecolsort.jar file (i.e., java -jar treecolsort.jar) the data is added in such a way as to produce the duplicate parent node. Clicking on the "Quantity" column will clean up the duplicate. I haven't been able to figure out a solution yet, but would love some new ideas on the topic. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: TreeTable: sorting leaf nodes via TableComparatorChooser |
| Free embeddable forum powered by Nabble | Forum Help |