If you are moving up or down (resequencing), then you don't want to
swap.  

 

You should be able to use removeItemAt(), which returns a reference to
the item removed, and addItemAt() to re-insert it.  You may need to
manipulate the indexes if you move an item "down", because removing the
item causes the indexes to adjust.

 

If you really want to swap, you should be able to do that also, again
paying attention to the indexes.  If you use the AC API, the UI should
refresh itself.

 

What issues are you having?

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of tony.grimes57
Sent: Tuesday, July 22, 2008 10:07 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] XMLListCollection and swapping DataGrid items

 

I have a datagrid that is fed by an XMLListCollection dataprovider.

I am trying to impliment a 'move up' / 'move down' feature with arrows 
so a user can reorder rows in the datagrid. 

I know reordering can be done via drag and drop, but does anyone have 
an example of what would effectively be a method looking like as 
follows:

XMLListCollection.swapItems(item1Index:int, item2Index:int); //where 
the method effectively takes the items at the given indexes and swaps 
them round

The idea being that you change the List Collection and the datagrid 
reflects these changes automatically (as is standard behaviour with 
dataproviders).

I can ALMOST get it working but i think it doesnt like more than one 
change to the collection at once and it may require a eventListener for 
the second part of teh swap. 

Any ideas / examples?

 

Reply via email to