Tree Questions

Hi,

Could anyone please assist me with the following, in relation to ITMill 5.3.0 rc9:

  1. Is there a function I can call on a tree, that will trigger whatever scrolling is required, to bring a nominated item into view. For example, if I have 1 root with 1000 child nodes under the 1 root in my tree, and I am on the first page, can I say something like tree.scrollIntoView(itemId) ?, where itemId is an item off the screen at the moment, and the ITMill Tree will scroll as required, to bring the itemId into view on the screen ? If there is no function for it, is there any way to achieve this ?

  2. Sorting at a given tree node level (ie. depth). Is there a way I can set up a java.util.Comparator, to perform the automatic sorting of nodes at the same level (ie. depth) in a tree, as they are being added ? If not, is there any other way to achieve this ?

  3. Node rendering. As far as I can tell, a node in a tree can have an optional icon and text, set by setItemIcon() and setItemCaption(). Is there any way I can have an arbitrary Component for a tree node, like I can have for a Table cell ? For example, If I want a Button, 2 Icons, and a caption for some nodes, and a Label and Button for another Tree node, is this possible, and if so, is there an example on how to do it ?

Thanks
Andrew

Hi Andrew. You have really good questions and I have really poor answers:

  1. Tree does not support lazy loading - it allways loads all the expanded nodes. In order to do what you described, you should either be using table or introduce additinal levels to the tree to keep number of childred smaller / level.
  2. Nope. Tree does not support sorting - it allways shows the nodes in the order given by the data source. To implement sorting, you should either use Table or implement sorting on data source level.
  3. Nope. Tree does not support putting arbitary components to the tree. If you decide to use table, then you can put any components to the table cells.

I hope this helps. If you give a more detailed description of your needs, maybe we could help you finding a workaround.

Joonas, I think you misunderstood the first question a bit.

Nonetheless, there is no functionality to scroll the selected item of a tree into view. This has been crossing our minds here several times, but no-one hasn’t even made a ticket about this feature.

So I suggest that you make tickets of each of these issues, and we’ll see if we can provide any of these in a timely manner.

In the meantime, try to implement some of these yourself (we’ll help here in the forums), or try to bug one of our developers enough to bite the bullet and do these features :slight_smile:

Oh… My bad.

In any case - we need that TreeTable badly :)

Hi,

Firstly, thanks for the quick response :slight_smile:

  1. Just a couple of ideas on this point:

a) If I select a node which is out of view, does selecting it programmatically bring it into view ?

b) Are there functions I can use to determine the currently navigated (not selected) node, and are there functions to control navigation: ie. scroll, and set navigated node within the current on screen view ?

  1. I assume you mean that I could implement a special Container I pass to setContainerDataSource(). Can you provide any basic instructions on what I would need to do, example can I override or reimplement some methods in IndexedContainer or ContainerHierarchicalWrapper ?

  2. Some ideas as partial workarounds:

a) Can I pass an Icon that is say 96x32 in size (instead of a normal Icon of 32x32), when I say setItemIcon(), so that I could effectively put 3 Icons side by side (horizontally) ?

b) Also, can I embed Image references (ie in the setItemText() call ? If so, what would the src root reference be - a directory under WEB-INF or somewhere else ?)

Of course any enhancements you could make to the current Tree would be greatly appreciated :slight_smile:

Thanks
Andrew

Hey Andrew,

Did you solve the above quote Issue? Can you help me in achieving this? I too face the same issue.

Thanks,
Gugan

For a), it should not take more than seconds to test yourself if you have an application with a Tree - just call tree.select(itemId) for an item id that is outside the view. I cannot recall which way Tree behaves, though I think it does scroll the selected item into view.

For b), there isn’t any API for controlling the focused item separately from selection. The server might not even know what is the focused item. As far as I can recall, there isn’t any server side API for scrolling a Tree to a specific node without changing the selection, either (unlike Table).

On the client side there is VTree.TreeNode.scrollIntoView(), but finding the correct TreeNode e.g. from an Extension might be tricky. Also note that it only works for nodes that the client side knows about, not nodes that are collapsed and haven’t been loaded from the server yet. In any case, client side development would be required and customizing parts of the client side class VTree might be needed (perhaps subclassing it and using GWT deferred binding to use your implementation), and this is likely to require some effort.