-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am using a tree to display a list of search results. When the user runs a new search, I completely replace all data in the tree with new results.
The problem I am having occurs when the new tree data has fewer results than the previously displayed tree. The tree object does not resize, but retains its full length, and it scrolls to the blank lines at the bottom of the list.
I can make the tree scroll to the top by using "setSelectedItem", but I don't want to do this. The application uses select events to retrieve more leaves for the tree, and this event will not trigger if the user clicks on an item that has been programmatically selected. (My users will be untrained members of the general public, so I cannot reasonably expect them to cope with this concept.)
My question is - Is there any other way I can force the tree to scroll to a place that actually contains some data? Alternatively, can I force the tree object to resize so that it does not contain blank pages?
Here is the zul definition of my tree:
<tree id="productTree" forward="onSelect=productfinder.onNodeSelect()" rows="10" width="360px"> </tree>
Here is how the tree is declared in java.
ArrayList allProducts = new ArrayList(); Tree productTree; SimpleTreeModel treeModel; SimpleTreeNode rootNode; rootNode = new PFTreeNode("Products", allProducts); //create the tree model treeModel = new SimpleTreeModel(rootNode);
Here is how I populate the tree model. The "places" list is retrieved using a call to a web service. (not shown)
{ for (int i = 0; i < places.size(); i++) { NamedPlace place = places.get(i); //if place name not in list of feature types to filter //add to list if (!this.placeNameFilterList.contains(place.getFeatureType())) { addGmarker(place); PFTreeNode placeNode = new PFTreeNode(place, new ArrayList()); allProducts.add(placeNode); } } } productTree.setModel(treeModel);
Before I refresh with a new query, I clear the model like this:
//clear the products list allProducts.clear(); //update the tree productTree.setModel(treeModel);
The actual data displayed is good. The tree contains all of the data that is expected. My only problem is that ZK forces the tree to scroll to the bottom and display a blank page. Can anyone please suggest how I can avoid this?
Thanks,
Chris
Asked: 2010-02-08 23:41:55 +0800
Seen: 816 times
Last updated: Feb 26 '19