Treemodel: Convenient way to update UI/model

asked 2008-06-22 06:50:19 +0800

admin gravatar image admin
18691 1 10 129
ZK Team

Orignial message at:

By: draymann

Hi there,

is there a convenient way to update a tree? I want to use drag'n'drop in a tree with a model to move nodes (changing order and attach them to other nodes).
The use of the notifyXYZ methods sometimes is a bit tricky, because you have to distinguish between many different situations.

I tried to circumvent this problem by a brute force refresh of the tree with calling tree.setModel(tree.getModel()). In order to restore the state of the tree you have to memorize the open/closed state of the treeitems beforehand and do appropriate setOpen's afterward. The only problem with this approach (apart from being not that performant for large trees) is, that in the UI the tree is scrolled to the top. Unfortunatley this makes this approach mostly impractical.

So here are my questions: is there a method to easily refresh the tree without the issues mentioned above? Something like tree.rebuild? Is there a way to get and restore the position if the tree is scrolled? Does anyone have another idea (maybe a generic(?) way to use the notifyXYZ methods)?

Let me say that I really am a big fan of this framework and I am sure, that I'll find a good solution for this problem with your help.

Thanks and have a nice weekend,


delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2008-07-01 01:35:13 +0800

admin gravatar image admin
18691 1 10 129
ZK Team

Orignial message at:

By: waterbottle

Have you ever read this small talk : http://www.zkoss.org/smalltalks/zkTreeModel/
, check code of TreeModelA.java,
fire a appropriate TreeDataEvent should works.


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2008-06-22 06:50:19 +0800

Seen: 361 times

Last updated: Jul 01 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More