Posted by Doug Hays on the 15th of June, 2007 at 11:34 pm under Flex.    This post has 34 comments.

In building a PositiveWare Project Tree for the Time Card, I found some great articles/posts on how to keep the open nodes of a tree after a dataProvider change:

 http://lordbron.wordpress.com/2006/07/28/flex-20-reopening-a-tree-after-updating-the-dataprovider/

http://www.adobe.com/devnet/flex/quickstart/working_with_tree/

 I tried out the solution and it worked very well for me… until the Time Card was released into the wild.

 First of all, here’s the setup.  It’s a Tree, inside of a HDividiedBox which is all popped up in a TitleWindow.  The user navigates through the Project Tree, finding the right Project or Task to track time against, enters the data and clicks save.

Now, the user wants to add a second entry and pops up the Add Time Card Entry window. 

 Two issues crept up:

  • A tree that initially is small enough to be completely visible, is expanded outside of the visible space,  and scroll bars appear.  The next time the tree is popped-up, the scroll bars don’t appear until a new node is opened or closed
  • A tree that is, when fully collapsed, larger than the visible space, will lose portions of the tree when popped up the second time.  For example, in a tree of states and their cities,  Ohio through Wyoming may not show up the second time… until you open, shut and scroll around a bit.

I wrangled with this oddity for an hour or so and right before packing it in for the night, I had the what-the-heck-lets-try-one-more-thing idea.

 Instead of:

SampleTree.openItems = open;

 I’m iterating through the items in open and calling expand:

 

if (open != null) { 

     for each(var obj : Object in open) {        

          expandItem(obj, true);   

       }

 }  

And all is well again in the Project Tree.

 

Sorry, but you have to log in to submit comments.