Hi Jason, 

You're on the right track.  You can edit your data directly and
through data binding the Tree control will update to reflect the
changes. See the Collections events for the notifications that the
Tree listens for.  

For the added node that doesnt display, I believe that you hit upon a
Tree bug.  The player should never crash though, so if you can
consistently crash it, please send me that file.  

Finally, regarding Collections and hierarchical data, there are no
standard Collections that can see a hierarchy, so moveNext and
movePrevious (IViewCursor) wont move up or down such a model.  The
cursor will get you across the top level nodes, but you're left with
using your own means for moving about the data from there.  This is
what I mean when I say that you use your own contract to interact with
the data.  

One thing to keep in mind regarding tree data, the Tree doesnt require
data to actually *be* hierarchical.  It only requires that it's
hierarchy can be described (via the ITreeDataDescriptor).  This is an
important distinction for things like, giant data sets, children with
multiple parents, paging result sets, relational data, etc. 

Also, what did you mean by "the XML approach is more supported", did
you mean via documentation? or did you find some issues with using
non-XML structures? 

Thanks and hope this helps,

-Michael


--- In flexcoders@yahoogroups.com, "Jason Y. Kwong" <[EMAIL PROTECTED]>
wrote:
>
> I'm really at a lost as to how we're supposed to work with the
hierarchical
> data that's used with the Tree component.  The XML approach seems to
be the
> most supported at the moment, so consider this simple XML:
> 
>    var rootNode: XML =
>    <node label="Root">
>       <node label="Child1"/>
>       <node label="Child2"/>
>    </node>
> 
> The dataProvider for the Tree then becomes an XMLListCollection.  It
> displays fine.  But now what's the expected way to modify the data
so that
> the Tree updates?  From the docs, I read:
> 
> "You can use the ICollectionView interface with list-based or
hierarchical
> data. The following sections describe the basic ICollectionView
operations
> using a list-based collection, but can also apply to similar
operations on a
> hierarchical collection."
> 
> How is ICollectionView used with hierarchical data?  Michael
Montagna gave a
> hint in the quoted code at the bottom, but it seems like
XMLListCollection
> is no more hierarchy-aware than ArrayCollection.  If I use a cursor
with the
> above example, I find that the collection has just one item--the
root node.
> I can add siblings to the root node via the cursor, but that's not very
> useful.  How do I get to the children via the collection/cursor?
> 
> So then I tried modifying the XML objects directly.  I tried doing this:
> 
>    [EMAIL PROTECTED] = "Hello";
> 
> And to my surprise, the Tree updated!  So I thought this was the answer.
> Well, sort of.  With the root node open in the Tree, I tried this:
> 
>    rootNode.appendChild(<node label="Child3"/>);
> 
> The Tree does update itself with a new row, but it shows up empty (I can
> select it, though).  If I collapse and expand the root, Child3 shows
up ok.
> Now, if I try this:
> 
>    rootNode.node[1].appendChild(<node label="Child3"/>);
> 
> The Flash Player crashes, taking the browser with it.  Looks like
converting
> a leaf to a branch while it's being displayed is a no-no.  Works ok
if the
> root node is collapsed.
> 
> Anyway, it looks like the Tree does get alerted for changes made
directly to
> the XML.  Is this an expected/acceptable way of doing things?  And
it just
> happens to be really buggy right now?  Or are we supposed to go
through the
> collection?  If so, how?
> 
> Suggestions?
> 
> 
> On 2/1/06, Michael Montagna <[EMAIL PROTECTED]> wrote:
> >
> > Here's a wordy example to add a leaf node:
> >
> > public function addTree() {
> >                 var collection:ICollectionView = ICollectionView(
> > myTree.dataProvider);
> >                 var cursor:IViewCursor = collection.getCursor();
> >                 cursor.seek(CursorBookmark.CURRENT, 2);
> >                 cursor.insert({label:"added item"});
> >                 cursor.release();
> >  }
> >
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to