Expanding root of tree in flex

This post is moved to http://srinichekuri.com/2014/02/21/expanding-root-of-tree-in-flex/

**********************************************************************

If you ever want to expand a tree (<mx:Tree>) immediately after setting dataprovider then follow this procedure. The challenge here is tree will not be ready to expand as it takes sometime for it to set data and render.

One common suggestion found on web is to use callLater() to call a function that has code to expand tree. This didn’t work for me (possibly because my code ran into same issue that I highlighted above). But following below method should definetly work as validateNow() method will make sure that all properties are set and will get the tree ready before expanding.

myTree.validateNow();
myTree.expandChildrenOf(_xml,true);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s