Tried this variation, same result…removes a folders child nodes but leaves the folder…don’t get it !!

 

var dp = view.profileFields.dataProvider;

 

for (var locNode :XMLNode = dp.firstChild; locNode != null;)

{

var exclude :Boolean = false;

      if ( locNode.toString() == nodes[0].toString() )

      {

            trace("TRUE");

            exclude = true;

      }

      var nextNode = locNode.nextSibling;

      if( exclude )

      {

            locNode.removeNode();

      }

      locNode = nextNode;

}

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Stacy Young
Sent: Wednesday, October 26, 2005 3:29 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Can't Seem to removeNode properly from a Tree!

 


I'm attempting to loop through childNodes on a tree dataprovider and
delete the currently selected node in that tree.

The tree's structure is fixed in that there is a series of child
elements in which each child may be one level deep.

When I execute the code below on an item off the root, its children are
deleted but the folder itself remains ??

Also, if it is a leaf I'm deleting it magically gets moved to the root
of the tree, yet is not deleted??

I must be missing something obvious here...any help would be much
obliged!

In the code snippet below, sections is the array of childnodes off the
root.

// Loop over sections
for(var i:Number=0; i<sections.length; i++)
{
      trace("step2");
      var fields = sections[i].childNodes;
      if( nodes[x] != sections[i] )
      {
            trace("step3");
            // Loop over fields
            for(var y:Number=0; y<fields.length; y++)
            {
                  trace("step4");
                  if( nodes[x] == fields[y] )
                  {
                        trace("step6: delete field");
                        var field :XMLNode = fields[y];
                        field.removeNode(); // Remove field
                        break;
                  }
            }
      } else {
            trace("step5: delete section");
            // Delete section
            sections[i].removeNode();
            break;
      }
}



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