[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
Got it working!!

I stepped through the code and could see that an index of -1 was being
thrown from Sort.as.  
I had applied a Sort to these XMLListCollections at an earlier point
in the application's lifecycle. 

I had to call .refresh() on the collection before I remove the item
and somehow this gets the collection all in nice shape and then
returns the correct index.

So now my code looks like this:

approvedList.addItem(myObject);


unApprovedList.refresh();
var index:int = unApprovedList.getItemIndex(myObject);
unApprovedList.removeItemAt(index);

Not sure why I had to explicitly call .refresh here.  I have other
XMLListCollections in my application that are sorted and I am able to
call .removeAt without always calling .refresh() first.

This brings me to another related question.  When you have a Sort
applied to an XMLListCollection, is there a way to "turn off" or reset
that Sort to some sort of default value?

--- In flexcoders@yahoogroups.com, "flexcoder2008"  wrote:
>
> Yes, I tried that and it is the correct node.
> 
> --- In flexcoders@yahoogroups.com, "Tracy Spratt"  wrote:
> >
> > trace(x.toXMLString());  //is that the node you expect?
> > 
> >  
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com
[mailto:flexcod...@yahoogroups.com] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 4:15 PM
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> >  
> > 
> > What is the best way to do this? I tried this line and it returned
> > true so it should be a good reference right?
> > 
> > var x:XML = unApprovedList[index];
> > trace(x == unApprovedList[index]);
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt"  wrote:
> > >
> > > Did you verify that var x:XML = unApprovedList[index]; is
returning a
> > > good reference?
> > > 
> > > 
> > > 
> > > Tracy Spratt 
> > > Lariat Services 
> > > 
> > > Flex development bandwidth available 
> > > 
> > > ____
> > > 
> > > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of flexcoder2008
> > > Sent: Thursday, February 19, 2009 3:57 PM
> > > To: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > > won't remove
> > > 
> > > 
> > > 
> > > Thanks Tracey - yes I am doing that as well.
> > > 
> > > I'm trying a new approach now - the problem now is that when I
try to
> > > retrieve the item index, even though I can see that the object is
> > > there, I am getting an index of -1. Is there something wrong with
> > > this code block?
> > > 
> > > approvedList.addItem(myObject.copy());
> > > 
> > > var index:int = 0;
> > > for each(var o:Object in unApprovedList){
> > > if(o.id == o.id.toString()){
> > > break;
> > > }
> > > else
> > > index++; 
> > > 
> > > }
> > > 
> > > var x:XML = unApprovedList[index];
> > > // x should refer to the same object in unApprovedList!
> > > 
> > > var index:int = unApprovedList.getItemIndex(x); // is returning -1
> > > unApprovedList.removeItemAt(index);
> > > 
> > > --- In flexcoders@yahoogroups.com
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > , "Tracy Spratt"  wrote:
> > > >
> > > > Good.
> > > > 
> > > > 
> > > > 
> > > > Are you using copy() when you addItem() to the approvedList?
> > > > 
> > > > 
> > > > 
> > > > Tracy Spratt 
> > > > Lariat Services 
> > > > 
> > > > Flex development bandwidth available 
> > > > 
> > > > 
> > > > 
> > > > From: flexcoders@yahoogroups.com
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:flexcod

[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
Yes, I tried that and it is the correct node.

--- In flexcoders@yahoogroups.com, "Tracy Spratt"  wrote:
>
> trace(x.toXMLString());  //is that the node you expect?
> 
>  
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 4:15 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
>  
> 
> What is the best way to do this? I tried this line and it returned
> true so it should be a good reference right?
> 
> var x:XML = unApprovedList[index];
> trace(x == unApprovedList[index]);
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt"  wrote:
> >
> > Did you verify that var x:XML = unApprovedList[index]; is returning a
> > good reference?
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 3:57 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > Thanks Tracey - yes I am doing that as well.
> > 
> > I'm trying a new approach now - the problem now is that when I try to
> > retrieve the item index, even though I can see that the object is
> > there, I am getting an index of -1. Is there something wrong with
> > this code block?
> > 
> > approvedList.addItem(myObject.copy());
> > 
> > var index:int = 0;
> > for each(var o:Object in unApprovedList){
> > if(o.id == o.id.toString()){
> > break;
> > }
> > else
> > index++; 
> > 
> > }
> > 
> > var x:XML = unApprovedList[index];
> > // x should refer to the same object in unApprovedList!
> > 
> > var index:int = unApprovedList.getItemIndex(x); // is returning -1
> > unApprovedList.removeItemAt(index);
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt"  wrote:
> > >
> > > Good.
> > > 
> > > 
> > > 
> > > Are you using copy() when you addItem() to the approvedList?
> > > 
> > > 
> > > 
> > > Tracy Spratt 
> > > Lariat Services 
> > > 
> > > Flex development bandwidth available 
> > > 
> > > 
> > > 
> > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of flexcoder2008
> > > Sent: Thursday, February 19, 2009 2:49 PM
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > > won't remove
> > > 
> > > 
> > > 
> > > The collections are independent. 
> > > When my app starts up I have an XML variable that gets split into 2
> > > seperate lists.
> > > 
> > > So for example:
> > > 
> > > var myList:XML
> > > 
> > > I then split the lists into 2 like so:
> > > 
> > > for each(var x:XML in myList){
> > > if(x.Status == "UnApproved") 
> > > unApproved.addItem(x.copy()); 
> > > else if(x.Status == "Approved") 
> > > approvedList.addItem(x.copy()); 
> > > }
> > > 
> > > I used the .copy() method to ensure that this isn't tied back to the
> > > original XML by reference.
> > > 
> > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > , "

RE: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread Tracy Spratt
trace(x.toXMLString());  //is that the node you expect?

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of flexcoder2008
Sent: Thursday, February 19, 2009 4:15 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
won't remove

 

What is the best way to do this? I tried this line and it returned
true so it should be a good reference right?

var x:XML = unApprovedList[index];
trace(x == unApprovedList[index]);

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt"  wrote:
>
> Did you verify that var x:XML = unApprovedList[index]; is returning a
> good reference?
> 
> 
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 3:57 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
> 
> 
> Thanks Tracey - yes I am doing that as well.
> 
> I'm trying a new approach now - the problem now is that when I try to
> retrieve the item index, even though I can see that the object is
> there, I am getting an index of -1. Is there something wrong with
> this code block?
> 
> approvedList.addItem(myObject.copy());
> 
> var index:int = 0;
> for each(var o:Object in unApprovedList){
> if(o.id == o.id.toString()){
> break;
> }
> else
> index++; 
> 
> }
> 
> var x:XML = unApprovedList[index];
> // x should refer to the same object in unApprovedList!
> 
> var index:int = unApprovedList.getItemIndex(x); // is returning -1
> unApprovedList.removeItemAt(index);
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt"  wrote:
> >
> > Good.
> > 
> > 
> > 
> > Are you using copy() when you addItem() to the approvedList?
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 2:49 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > The collections are independent. 
> > When my app starts up I have an XML variable that gets split into 2
> > seperate lists.
> > 
> > So for example:
> > 
> > var myList:XML
> > 
> > I then split the lists into 2 like so:
> > 
> > for each(var x:XML in myList){
> > if(x.Status == "UnApproved") 
> > unApproved.addItem(x.copy()); 
> > else if(x.Status == "Approved") 
> > approvedList.addItem(x.copy()); 
> > }
> > 
> > I used the .copy() method to ensure that this isn't tied back to the
> > original XML by reference.
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt"  wrote:
> > >
> > > First, are you sure your collections are independent? If you use
the
> > > same XMLList for both, they are not.
> > > 
> > > 
> > > 
> > > Tracy Spratt 
> > > Lariat Services 
> > > 
> > > Flex development bandwidth available 
> > > 
> > > 
> > > 
> > > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>

[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
What is the best way to do this?  I tried this line and it returned
true so it should be a good reference right?

var x:XML = unApprovedList[index];
trace(x == unApprovedList[index]);


--- In flexcoders@yahoogroups.com, "Tracy Spratt"  wrote:
>
> Did you verify that var x:XML = unApprovedList[index]; is returning a
> good reference?
> 
>  
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 3:57 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
>  
> 
> Thanks Tracey - yes I am doing that as well.
> 
> I'm trying a new approach now - the problem now is that when I try to
> retrieve the item index, even though I can see that the object is
> there, I am getting an index of -1. Is there something wrong with
> this code block?
> 
> approvedList.addItem(myObject.copy());
> 
> var index:int = 0;
> for each(var o:Object in unApprovedList){
> if(o.id == o.id.toString()){
> break;
> }
> else
> index++; 
> 
> }
> 
> var x:XML = unApprovedList[index];
> // x should refer to the same object in unApprovedList!
> 
> var index:int = unApprovedList.getItemIndex(x); // is returning -1
> unApprovedList.removeItemAt(index);
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt"  wrote:
> >
> > Good.
> > 
> > 
> > 
> > Are you using copy() when you addItem() to the approvedList?
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 2:49 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > The collections are independent. 
> > When my app starts up I have an XML variable that gets split into 2
> > seperate lists.
> > 
> > So for example:
> > 
> > var myList:XML
> > 
> > I then split the lists into 2 like so:
> > 
> > for each(var x:XML in myList){
> > if(x.Status == "UnApproved") 
> > unApproved.addItem(x.copy()); 
> > else if(x.Status == "Approved") 
> > approvedList.addItem(x.copy()); 
> > }
> > 
> > I used the .copy() method to ensure that this isn't tied back to the
> > original XML by reference.
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt"  wrote:
> > >
> > > First, are you sure your collections are independent? If you use the
> > > same XMLList for both, they are not.
> > > 
> > > 
> > > 
> > > Tracy Spratt 
> > > Lariat Services 
> > > 
> > > Flex development bandwidth available 
> > > 
> > > 
> > > 
> > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of flexcoder2008
> > > Sent: Thursday, February 19, 2009 2:27 PM
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > > won't remove
> > > 
> > > 
> > > 
> > > I should make a correction...the 2nd example doesn't workwhere I
> > > am using the delete with an index. That just removes one of the
> nodes
> > > of the object itself.
> > > 
> > > So I am still stuck as to how to successfully remove a shared object
> > > between 1 list and another and have the item removed from 1 datagrid
> > > and added to another.
> > > 
> > > --- In flexcoders@yahoogroups.com

RE: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread Tracy Spratt
Did you verify that var x:XML = unApprovedList[index]; is returning a
good reference?

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of flexcoder2008
Sent: Thursday, February 19, 2009 3:57 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
won't remove

 

Thanks Tracey - yes I am doing that as well.

I'm trying a new approach now - the problem now is that when I try to
retrieve the item index, even though I can see that the object is
there, I am getting an index of -1. Is there something wrong with
this code block?

approvedList.addItem(myObject.copy());

var index:int = 0;
for each(var o:Object in unApprovedList){
if(o.id == o.id.toString()){
break;
}
else
index++; 

}

var x:XML = unApprovedList[index];
// x should refer to the same object in unApprovedList!

var index:int = unApprovedList.getItemIndex(x); // is returning -1
unApprovedList.removeItemAt(index);

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt"  wrote:
>
> Good.
> 
> 
> 
> Are you using copy() when you addItem() to the approvedList?
> 
> 
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 2:49 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
> 
> 
> The collections are independent. 
> When my app starts up I have an XML variable that gets split into 2
> seperate lists.
> 
> So for example:
> 
> var myList:XML
> 
> I then split the lists into 2 like so:
> 
> for each(var x:XML in myList){
> if(x.Status == "UnApproved") 
> unApproved.addItem(x.copy()); 
> else if(x.Status == "Approved") 
> approvedList.addItem(x.copy()); 
> }
> 
> I used the .copy() method to ensure that this isn't tied back to the
> original XML by reference.
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt"  wrote:
> >
> > First, are you sure your collections are independent? If you use the
> > same XMLList for both, they are not.
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 2:27 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > I should make a correction...the 2nd example doesn't workwhere I
> > am using the delete with an index. That just removes one of the
nodes
> > of the object itself.
> > 
> > So I am still stuck as to how to successfully remove a shared object
> > between 1 list and another and have the item removed from 1 datagrid
> > and added to another.
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "flexcoder2008"  wrote:
> > >
> > > 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)
>

[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
Thanks Tracey - yes I am doing that as well.

I'm trying a new approach now - the problem now is that when I try to
retrieve the item index, even though I can see that the object is
there, I am getting an index of -1.  Is there something wrong with
this code block?

approvedList.addItem(myObject.copy());

var index:int = 0;
for each(var o:Object in unApprovedList){
  if(o.id == o.id.toString()){
break;
  }
  else
index++;

}


var x:XML = unApprovedList[index];
// x should refer to the same object in unApprovedList!

var index:int = unApprovedList.getItemIndex(x); // is returning -1
unApprovedList.removeItemAt(index);



--- In flexcoders@yahoogroups.com, "Tracy Spratt"  wrote:
>
> Good.
> 
>  
> 
> Are you using copy() when you addItem() to the approvedList?
> 
>  
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 2:49 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
>  
> 
> The collections are independent. 
> When my app starts up I have an XML variable that gets split into 2
> seperate lists.
> 
> So for example:
> 
> var myList:XML
> 
> I then split the lists into 2 like so:
> 
> for each(var x:XML in myList){
> if(x.Status == "UnApproved") 
> unApproved.addItem(x.copy()); 
> else if(x.Status == "Approved") 
> approvedList.addItem(x.copy()); 
> }
> 
> I used the .copy() method to ensure that this isn't tied back to the
> original XML by reference.
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt"  wrote:
> >
> > First, are you sure your collections are independent? If you use the
> > same XMLList for both, they are not.
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 2:27 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > I should make a correction...the 2nd example doesn't workwhere I
> > am using the delete with an index. That just removes one of the nodes
> > of the object itself.
> > 
> > So I am still stuck as to how to successfully remove a shared object
> > between 1 list and another and have the item removed from 1 datagrid
> > and added to another.
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "flexcoder2008"  wrote:
> > >
> > > 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?
> > >
> >
>




RE: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread Tracy Spratt
Good.

 

Are you using copy() when you addItem() to the approvedList?

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of flexcoder2008
Sent: Thursday, February 19, 2009 2:49 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
won't remove

 

The collections are independent. 
When my app starts up I have an XML variable that gets split into 2
seperate lists.

So for example:

var myList:XML

I then split the lists into 2 like so:

for each(var x:XML in myList){
if(x.Status == "UnApproved") 
unApproved.addItem(x.copy()); 
else if(x.Status == "Approved") 
approvedList.addItem(x.copy()); 
}

I used the .copy() method to ensure that this isn't tied back to the
original XML by reference.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt"  wrote:
>
> First, are you sure your collections are independent? If you use the
> same XMLList for both, they are not.
> 
> 
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 2:27 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
> 
> 
> I should make a correction...the 2nd example doesn't workwhere I
> am using the delete with an index. That just removes one of the nodes
> of the object itself.
> 
> So I am still stuck as to how to successfully remove a shared object
> between 1 list and another and have the item removed from 1 datagrid
> and added to another.
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "flexcoder2008"  wrote:
> >
> > 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?
> >
>





[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
The collections are independent.  
When my app starts up I have an XML variable that gets split into 2
seperate lists.

So for example:

var myList:XML

I then split the lists into 2 like so:

for each(var x:XML in myList){
 if(x.Status == "UnApproved") 
  unApproved.addItem(x.copy()); 
 else if(x.Status == "Approved") 
  approvedList.addItem(x.copy()); 
}


I used the .copy()  method to ensure that this isn't tied back to the
original XML by reference.


--- In flexcoders@yahoogroups.com, "Tracy Spratt"  wrote:
>
> First, are you sure your collections are independent?  If you use the
> same XMLList for both, they are not.
> 
>  
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 2:27 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
>  
> 
> I should make a correction...the 2nd example doesn't workwhere I
> am using the delete with an index. That just removes one of the nodes
> of the object itself.
> 
> So I am still stuck as to how to successfully remove a shared object
> between 1 list and another and have the item removed from 1 datagrid
> and added to another.
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "flexcoder2008"  wrote:
> >
> > 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?
> >
>




RE: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread Tracy Spratt
First, are you sure your collections are independent?  If you use the
same XMLList for both, they are not.

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of flexcoder2008
Sent: Thursday, February 19, 2009 2:27 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
won't remove

 

I should make a correction...the 2nd example doesn't workwhere I
am using the delete with an index. That just removes one of the nodes
of the object itself.

So I am still stuck as to how to successfully remove a shared object
between 1 list and another and have the item removed from 1 datagrid
and added to another.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "flexcoder2008"  wrote:
>
> 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?
>





[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove

2009-02-19 Thread flexcoder2008
I should make a correction...the 2nd example doesn't workwhere I
am using the delete with an index.  That just removes one of the nodes
of the object itself.

So I am still stuck as to how to successfully remove  a shared object
between 1 list and another and have the item removed from 1 datagrid
and added to another.


--- In flexcoders@yahoogroups.com, "flexcoder2008"  wrote:
>
> 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?
>