I am having all sorts of problems with removing items from an
XMLListCollection.  Not sure if this is because the dataBinding is
preventing the items from being removed or not - I'm hoping someone
who has run into this issue as well can give me some insight.

I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid.

There is an approvedItemList bound to dgApproved, and an
unApprovedList bound to dgUnApproved.

Sometimes, I want to remove an object from the 1 list, and then add it
to the other list.  (I am using Cairngorm by the way)

For example, I want to take an item in the unApprovedList and add it
to the ApprovedList.  So first I would add the object to the
ApprovedList, and then get the Index of the object in the
UnApprovedList and use RemoveAt like so:

approvedList.addItem(myObject);
var index:int = unApprovedItemList.getItemIndex(myObject);
unApprovedList.removeAt(index);

I am looking at the collections in the watch window, and I can see
that when the .removeAt fires, the object is still left in the
unApprovedList!  Why is this happening?

I then attempted to remove the item this way as a workaround:

approvedList.addItem(myObject);
                
var index:int = 0;
for each(var o:Object in unApprovedList){
    if(o.Id == myObject.Id.toString()){
        delete o[index];
        break;
    }
    else
        index++;        
                        
}

Here again, when the delete command gets hit, the line executes, but
the object is left in the collection.  I am left with 2 copies, the
newly added one in the approvedList, and the leftover copy that I've
tried to delete in the unApprovedList.

Is the databinding somehow making a copy or "locking" that object?





Reply via email to