Reputation: 473
I try to switch from JFace TreeViewer to NatTable. Unfortunately I didn't find a lot of documentation about implementing trees with NatTable. So I have some questions
With TreeViewer I used setInput()
to provide new input. How can I achieve the same with NatTable? Is it a proper way to call clear()
and addAll()
on underlying data source List
? (I use GlazedLists)
I use described clear()
/addAll()
way to pass new data after querying a database. And after it expanded state of tree is lost, all nodes are colapsed. With JFace TreeViewer I used
getExpandedElements()
/ setExpandedElements()
to keep expanded state. Is there something similar available in NatTable?
Is it possible to load child tree nodes only when parent node is clicked? I can't build beforehand all tree data because I can have cycles in it (well, strictly speaking my data is not really a tree, but it's convenient to display it like a tree)
UPD: Not sure if I should ask it here or create separate question
My problem: after sorting on any column other than 'tree' column child nodes can move to invalid parent. Though the order of elements is correct on all levels of hierarchy. I use SortableTreeComparator
and as treeComparator
I use my custom comparator (not GlazedLists.beanPropertyComparator
as in example). What can be wrong here?
Upvotes: 1
Views: 1172
Reputation: 4231
IDataProvider
is able to provide the data in a two-dimensional way. Because of our abstraction levels, we don't have a setInput()
in NatTable. With 1.4 we opened the API to be able to set the IDataProvider
to the DataLayer
at runtime, which is something similar.ExpansionModel
that remembers the expansion state. In NatTable we have the same in the GroupByExpansionModel
because of the same reaons.ITreeRowModel
that performs the lazy loading on expand if necessary. I would suggest to extend GlazedListTreeRowModel
and check the various expand methods that you need to override.Upvotes: 1
Reputation: 679
First, you can look in NatTable examples and look at the way the tree is implemented.
ca.odell.glazedlists.TreeList.ExpansionModel
which is part of the TreeList
you use as input.Upvotes: 1