Hi,

I have a name list with order that saved in a ArrayCollection.I want to
use DataGrid to change order with drag and drop then save to a new
arraycollection.but I do not know how to go over all the datagrid and
the fillowing code doesn't work.Please give me a idea to fix it.Thanks.

Mark

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
<mx:Script>
        <![CDATA[
                import mx.controls.Alert;
                import mx.collections.ArrayCollection;          
                  
                [Bindable]
                private var myCollection:ArrayCollection =  new
ArrayCollection([{order: '1', name: 'Matthews'},{order: '2', name:
'Mark'},{order: '3', name: 'Tony'}]);
                
                private var myCollection1:ArrayCollection = new 
ArrayCollection();
                
                
                private function finishit():void{
                        
                  for(var i:Number; i<myCollection.length;i++){
                         
                         var obj:Object = new Object();
                         obj.order = String(i+1);
                         obj.name = dg1.selectedItems[i].name;
                         
                     myCollection1.addItem(obj);
                     
                  }
                  
                  //Alert.show(myCollection.length.toString());
                } 
                
                
        ]]>
</mx:Script>
 
        <mx:DataGrid  id="dg1" x="105" y="149" dataProvider="{myCollection}"
dragEnabled="true" dragMoveEnabled="true"
                 dropEnabled="true" dragDrop="finishit()"  >
                <mx:columns>
                        
                        <mx:DataGridColumn headerText="Name List" 
dataField="name"/>
                 
                </mx:columns>
        </mx:DataGrid>
        
</mx:Application>


Reply via email to