That helps alot - thanks!

On 2/1/06, Michael Montagna <[EMAIL PROTECTED]> wrote:
Hi Gunnar,

The Tree control no longer provides fine grained access to the nodes and node attributes of the underlying data model, instead you can use your own contract with the data directly.  So if you want to read or change your data, you would do so on that data without going through the Tree control to do so.

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();
 }

For the selectedNode you mentioned where you are returned your XML node data, you could use e4x or the XML methods. Something like [EMAIL PROTECTED] and [EMAIL PROTECTED] for attributes, or .children() to get the lower level nodes.   It would be the same thing with sealed classes or dynamic objects, but in those cases you'd use different accessors as defined by the data.

Here's a selectedNode example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.macromedia.com/2005/mxml">

   <mx:Script>
     <![CDATA[
        [Bindable]
        public var selectedNode:Object;
          
        public function treeChanged(event:Event):void {
           selectedNode=Tree(event.target).selectedNode;
        }
     ]]>
   
   </mx:Script>
   
   <mx:HDividedBox width="100%" height="100%">
      <mx:Tree id="myTree" width="50%" height="100%"
                 labelField="@label" rootVisible="false"
                 change="treeChanged(event)">
          <mx:dataProvider>
              <mx:XML format="e4x">
                  <node label="Mail Box">
                    <node label="Inbox">
                        <node label="Marketing"/>
                        <node label="Product Management"/>
                        <node label="Personal"/>
                    </node>
                    <node label="Outbox">
                        <node label="Professional"/>
                        <node label="Personal"/>
                    </node>
                    <node label="Spam"/>
                    <node label="Sent"/>
                </node>
              </mx:XML>
          </mx:dataProvider>
      </mx:Tree>
      <mx:TextArea height="100%" width="50%" text="Selected Item: {selectedNode [EMAIL PROTECTED]}"/>
   </mx:HDividedBox>  
</mx:Application>


Hope this helps,

-Michael


--- In flexcoders@yahoogroups.com, gunnar a reinseth <[EMAIL PROTECTED]> wrote:
>
> Although the changes/fixes to the Tree control are much appreciated (e.g.
> not selecting the node when expanding it, and percentage width issues), I'm
> left wondering how you're supposed to add/remove child nodes to a node in
> the tree... When I use the new tree.getNodeDisplayedAt() method - or
> tree.selectedNode property - what is returned is an XML representation of
> the node. How should i go about with the new api?
>
> --
> gunnar
>


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




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS






--
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




Reply via email to