Alex Zhou
Alex Zhou

Reputation: 139

Flex Tree vertical scrolling problem

I am using mx:Tree (in Flex 4), and assigned a customised MXTreeItemRenderer for every items. As the TreeItemRenderer contains a list with tileLayout, which means the height of every row is variable. So I have to set the tree's "variableRowHeight to true. When I was testing the tree, everything went well. But when I was using the vertical scroller, I met some problems:

  1. The scroll bar did not move to the position I want. When I was scrolling the content, the scroll bar sometimes scrolled to a unwanted position (e.g. the head of the tree). When there are more rows, the problem is more obvious.

  2. When I was scrolling the tree, the images were flicking all the time. That means, the images are reloading I guess. any help?

Is there anyone who can help me solve the problems? many thx :)

Upvotes: 0

Views: 2846

Answers (2)

James Fiala
James Fiala

Reputation: 21

One way that I found helpful was to just wrap the tree in a canvas. I was having the same problem with the tree's scrolling because it would do all sorts of funky things, but when you allow the canvas to handle the scrolling instead of the tree everything works out. I chose this over replacing it with the spark tree just because it was a nice quick fix.

<mx:Canvas height="100%" width="100%" verticalScrollPolicy="on">                                       
     <mx:Tree width="100%" height="100%"                                
     click="click_handler(event);"                                                      
     verticalScrollPolicy="off"                                
     itemRenderer="com.fti.view.itemRenderers.defaultRenderer"
     itemClose="{treeSample.height = treeSample.measureHeightOfItems();}"
     itemOpen="{treeSample.height = treeSample.measureHeightOfItems();}"                                     
     id="treeSample"
 variableRowHeight="true"/> 
</mx:Canvas>

Be sure and include those itemClose and itemOpen properties so the canvas is able to accurately set the height and scroll properly. One warning is that if you're working with larger trees, this can be a bit heavy and impact performance.

Upvotes: 2

Yordan Yanakiev
Yordan Yanakiev

Reputation: 2604

use SparkTree

http://kachurovskiy.com/2010/spark-tree/

there is too much bugs with the current tree. ( whating for Flex 5 to clean out thoose things finally ) :)

Upvotes: 0

Related Questions