I am working on a modified shopping cart examples and using
it to build a event registration RIA. People are able to drag and
drop items from the event datagrid into their registration
datagrid. They are able to choose multiple events to register for
and can also remove items once added.
Below is the code processing the addition of an item to the
registration datagrid (targetGridDP). The removePerson function
removes the item from the datagrid but I am confused how to remove
it from the Array of event ID numbers. I assume I need a for loop
but I was wondering if I am missing something easier.
Just to let you know, my goal is to send the array out with
an HTTP Service to the server where I will loop through and
register the user for each event ID in the array.
Thanks!
Yours in playing with Arrays,
Jon
%26lt;![CDATA[
import mx.events.DragEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.DragEvent
[Bindable]
private var targetGridDP:ArrayCollection=new ArrayCollection
public var listOfEvents:String=''''
public var myArray:Array = new Array();
public function jon(event:DragEvent):void{
var dgRow:Object=new Object()
dgRow=event.dragSource.dataForFormat(''items'')
myArray.push(String(dgRow[0].id))
Alert.show(String(myArray))
}
// Remove a person from the ArrayCollection.
public function removePerson():void {
// Make sure an item is selected.
if (dg.selectedIndex %26gt;= 0) {
targetGridDP.removeItemAt(targetGrid.selectedIndex);
//HERE IS WHERE I AM CONFUSED HOW TO REMOVE THE ITEM OUT OF
MY STORED ARRAY (myArray). I KNOW THE VALUE OF THE ITEM BUT NOT ITS
LOCATION IN THE ARRAY AND FROM WHAT I CAN TELL YOU CAN ONLY REMOVE
ARRAY ITEMS BY ITS LOCATION IN THE ARRAY ie. pop, shift, splice.
delete doesnt seem like a good use here.
}
}
]]%26gt;
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment