Sure you get to disagree with Adobe all you want!

 

Your solution is fine, but watch for performance issues if the tree gets
large.  You don't theoretically need to recurse the whole tree to do
what you want.

 

openIndices, huh?  Isn't there a problem wherein "index" is linear, but
the tree is hierarchical?

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Oliver Merk
Sent: Wednesday, January 03, 2007 9:35 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Tree: Resetting openItems after dataProvider
change

 

@Tracy & Hank: Thanks very much for the feedback and suggestions.
Tracy, I clearly understand that the data drives the behavior of the
tree. I do, however, disagree with Adobe's changes to the tree control
in Flex 2.

Here's why: The concept of a node being opened or closed, has no
corollary in the ArrayCollection or XMLListCollection data structures.
That is, an ArrayCollection element has no concept of being "open".
This is a concept related to the Tree control. So the act of restoring
the open/closed state of a tree's nodes should IMHO be a lot easier
than jumping through the hoops we've all suggested.

If, as I originally suggested, there was a openIndices property,
similar in concept to the openItems property which already exists, I'd
be able to restore the tree's visual appearance *independent* of the
data -- which, in my case of switching languages at runtime is exactly
what I need to do.

I have achieved a working prototype by adding an attribute to the
branch nodes' XML, tracking the open and close events and recursing
through the data to restore the opened states after the data has
changed; but again, IMHO it should not be this hard;)

Thanks again,
Oliver

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Yes, Hank's solutionsis what I would do.
> 
> 
> 
> Further, when you say "...Flex 2 tree control limits direct access to
> nodes...", you make me suspect you are making a conceptual mistake.
> With data-driven controls, you never directly access the controls
> themselves. Rather, you work with the dataProvider, to which you have
> full access.
> 
> 
> 
> So in your case, you would have the unique id on each element(XML
> object/node) in your XMLListCollection, and you would store the open
> nodes in some list. I think an associative array(hash table) would be
> the most efficient. The function to open those nodes would need to be
> recursive. When your recursive function matches a node in the
> associative array, you would need to climb back up the tree, parent by
> parent, opening each node as you go, till you reach an alrady open
node.
> Might be a bit more compilcated than that, since you want to reach the
> end of a recursion branch before you stop searching.
> 
> 
> 
> If you post an example of two sample matching xml docs, with the above
> mentioned ids, I might try to implement this functionality as an
> example.
> 
> 
> 
> Tracy
> 
> 
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of hank williams
> Sent: Sunday, December 24, 2006 7:51 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: Re: [flexcoders] Tree: Resetting openItems after dataProvider
> change
> 
> 
> 
> I think you are on track with the idea of needing an "open indices"
> property. But indicices are a bit messy in a tree. what would be best
is
> a set of common unique identifiers. A field in each node that is
unique.
> This will allow you to build a function that creates a list of the ids
> that are open, and another function that opens those nodes. The nodes
> will have the same id no matter what language the actual text of the
> tree item is. gathering the ids from the open items, and opening the
> items that have a given list of ids should be relatively straight
> forward. 
> 
> Regards,
> Hank
> 
> On 12/23/06, Oliver Merk <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > wrote:
> 
> I've been wrestling with this for over a week and haven't found a
> solution to this problem. Hoping someone can help.
> 
> I have a tree control that, at runtime, changes its dataProvider. In
> this case, I'm switching languages and the dataProvider format is 
> XMLListCollection. I'd like to restore the open items of the tree
> after the dataProvider has changed. I tried using the openItems
> property, but openItems stores a list of XML objects from the original
> dataProvider. 
> 
> When the provider changes, the XML objects are of course different,
> and trying to reset the openItems property fails. What I really need
> is an "openIndices" property that is not tied to the XML data in the 
> provider.
> 
> The example Adobe gives
> (http://www.adobe.com/devnet/flex/quickstart/working_with_tree/
<http://www.adobe.com/devnet/flex/quickstart/working_with_tree/> 
> <http://www.adobe.com/devnet/flex/quickstart/working_with_tree/
<http://www.adobe.com/devnet/flex/quickstart/working_with_tree/> > ) is
> not helpful since they switch between two dataProviders with the same 
> content and they're using an ArrayCollection (I'm using an
> XMLListCollection).
> 
> I've tried walking the tree but since the new Flex 2 tree control
> limits direct access to nodes, I could not find a way to detect the 
> open indexes of the tree directly.
> 
> Any ideas?
> 
> Thanks,
> Oliver
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> 
> <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> > 
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
<http://www.mail-archive.com/flexcoders%40yahoogroups.com> 
> <http://www.mail-archive.com/flexcoders%40yahoogroups.com
<http://www.mail-archive.com/flexcoders%40yahoogroups.com> > 
> Yahoo! Groups Links
> 
> 
> (Yahoo! ID required)
> 
> mailto:[EMAIL PROTECTED]
<mailto:flexcoders-fullfeatured%40yahoogroups.com> 
> <mailto:[EMAIL PROTECTED]
<mailto:flexcoders-fullfeatured%40yahoogroups.com> >
>

 

Reply via email to