Hank, you are absolutely correct, the amazing e4x selection expressions
will replace the recursive function.  I guess I did so many recursive
functions for this in 1.5 that I was temporarily stupid.  And the ID
values can be stored in a simple Array, and looped over.

 

I believe he will still need to climb the ancestor chain to open the
parents of the found nodes though.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of hank williams
Sent: Wednesday, December 27, 2006 9:26 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Tree: Resetting openItems after dataProvider
change

 

Actually, Tracy, I dont think you need to do all of this work. The
openItems field of the tree does it for you. So you just need to go
through the openItems array of nodes and gather all the item IDs that I
described in the prior email. 

To reopen them later, you just use the an e4x function (I forget the
syntax but I can look if necessary) to find all the items in the
dataprovider that have the given ID. You then open each one of these
nodes.

Hank

On 12/26/06, Tracy Spratt <[EMAIL PROTECTED]
<mailto:[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@yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ]
On Behalf Of hank williams
Sent: Sunday, December 24, 2006 7:51 AM
To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.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/> ) 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> 
Search Archives:
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:[EMAIL PROTECTED]> 



 

 

 

Reply via email to