Is it possible to set a rowfilter on a JXTreeTable; so far, my efforts have failed to filter any rows... is it possible? Or do I have to use some other mechanism to remove unwanted nodes (always leaf nodes) from the display?
Well, I have written a quick'n'dirty approach of the above idea.
This was the triggering question with the answer:
and this is the code:
JXTreeTable is not sortable despite being a subclass of JXTable. We simply do not have a sorter capable of displaying the data as we would expect. setRowSorter is overridden to do nothing.
We are collecting ideas for how to sort JXTree(Table)s in the wiki, but nothing in progress yet.
Filtering should be different than sorting. Sorting may rearrange nodes relationship keeping the model structure visible. Filtering should hide parent/child nodes from the view. Despite of sound similarly, filtering should not imply sorting, as it less "destructive" in a hiearchichal data.
What should mean sorting a tree anyway? You could end up a child being a parent of its parent because now sorting precedes in the hierarchy. That's something I don't want. I want to keep my hiearchy.
Filtering, instead, should only show/hide nodes without altering the hiearchy. That would be something like pruning the tree.
Filtering could also have the option of pruning the tree including the subtree of the node found. So, when you found a node, you stop filtering in its children and continue pruning the rest of the tree.
Basically, I think you could implement filtering by having a filteredRoot and moving nodes (subtrees) to that filteredRoot. When removing the filter, nodes will be added to their original parents, always keeping the hiearchy in the tree.
I'm working in the above idea of filtering. A parallel model which stores a Map of relationship child->parent to be later on restored when filter is removed. Then filtering reduces to move nodes to a filteredRoot and then restored when filter is removed.
The problem is that core supports filtering out of sorting. I guess we could only support identity sorting...
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.