您的位置:首页 > 其它

用delete删除XML和XMLListCollection的节点

2010-09-15 14:24 260 查看

Problem Summary

simply using the Delete key work in Flex does not work most of the time and if you have a Tree that's bound to the XMLListCollection Flex will mess up the Tree Selection after deleting an XML element.

Solution Summary

Use a custom method to for loop and delete proper child and reset tree selection

Explanation

Use this method:

private function xmlDeleteNode(xmlToDelete:XML):Boolean
{
var cn:XMLList = XMLList(xmlToDelete.parent()).children();

for ( var i:Number = 0 ; i < cn.length() ; i++ )
{
if ( cn[i] == xmlToDelete )
{
delete cn[i];
return true;
}
}

return false;

}

Also, remember to do on an XML Bound Tree Control:

myTree.selectedItem = null;

注:XMLList 不支持 delete
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐