Scroll to selected Treeitem doesn't work for the first output

asked 2009-10-13 23:56:35 +0800

robertpic71 gravatar image robertpic71
1275 1

I try to migrate my very first ZK application to ZK 3.6.2 / 5.0RC. But (unlike the old 3.0.x version) the scroll to selected Treeitem doesn't work. After some research i could reproduce the problem:

There is no autoscroll (to the selectedItem) after the tree is rendered the first time. Check this demo:

The first output does not scroll to the bottom of the tree - but the last item is selected. The buttons works.

Tested with 3.5.0 Prof, 3.6.0 Std, 3.6.2 Prof, 5.0RC

I post a bug.

<window id="win" title="tree checkmark demo" border="normal" height="600px">
Treeitem posItem1;
Treeitem posItem2;
void create() {
  for(int i=0; i != 45; i++) {
	Treeitem item = new Treeitem();
	Treerow row = new Treerow();
	Treecell cell = new Treecell();
	cell.label = "Item " + i;
	if (i==0) {
	   posItem1 = item;
	if (i==44) {
	   posItem2 = item;
	   // item.selected = true;  // doesn't help
  tree.selectedItem= posItem2;
	<button label="Pos1" onClick="tree.selectedItem = posItem1;"/>
	<button label="Pos2" onClick="tree.selectedItem = posItem2;" />
	<separator bar="true" />
	<tree id="tree" width="90%"  vflex="true"
		checkmark="false"  rows="20" onCreate="create()">
		<treechildren id="child">


BTW: My complex tree building is not rendered by 5.0RC - no error to see :-(

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-10-14 00:53:58 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

we don't design to autoscroll after rendered, it is not ours specification
you can use timmer to set selectedItem

link publish delete flag offensive edit

answered 2009-11-03 08:37:02 +0800

robertpic71 gravatar image robertpic71
1275 1

Hi, i have finished my "autoscroll".

First i post this as bug, because it is a "lost" feature, because it works in older ZK Versions (i think it was 3.0.2).

However i solved the problem like your suggest with a timer.

Another issue: the tree has to known any height (pixel/rows), otherwise the autoscroll won't work correctly.


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: 2009-10-13 23:56:35 +0800

Seen: 621 times

Last updated: Nov 03 '09

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