Remove data from DataGrid : DataGrid Data « Grid « Flex






Remove data from DataGrid

Remove data from DataGrid
       


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    
      import mx.collections.ArrayCollection;
      import mx.controls.DataGrid;
      import mx.events.DragEvent;
      import mx.managers.DragManager;
      private function dragCompleteHandler(event:DragEvent):void {
        if(event.action != DragManager.NONE) {
          var grid:DataGrid = DataGrid(event.dragInitiator);
          var data:ArrayCollection = ArrayCollection(grid.dataProvider);
          var item:Object = event.dragSource.dataForFormat("items")[0];
          for(var i:uint = 0; i < data.length; i++) {
            if(data.getItemAt(i).emailId == item.emailId) {
              data.removeItemAt(i);
              break;
            }
          }
        }
      }

  
  </mx:Script>
      <mx:DataGrid dropEnabled="true" dragEnabled="true" dragComplete="dragCompleteHandler(event)">
        <mx:columns>
          <mx:DataGridColumn headerText="From" dataField="from"/>
        </mx:columns>
        <mx:dataProvider>
          <mx:ArrayCollection>
            <mx:Object emailId="0" from="a@a.com"/>
          </mx:ArrayCollection>
        </mx:dataProvider>
      </mx:DataGrid>
      <mx:DataGrid dropEnabled="true" dragEnabled="true" dragComplete="dragCompleteHandler(event)">
        <mx:columns>
          <mx:DataGridColumn headerText="From" dataField="from"/>
        </mx:columns>
      </mx:DataGrid>
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Get data from DataGrid in drag enter eventGet data from DataGrid in drag enter event
2.Fill data from DataGrid to Form fieldsFill data from DataGrid to Form fields
3.Update data in DataGrid from Form fieldsUpdate data in DataGrid from Form fields
4.ArrayCollection used as the data source for DataGridArrayCollection used as the data source for DataGrid
5.Inline data provider for DataGridInline data provider for DataGrid
6.Passing data to a DataGrid controlPassing data to a DataGrid control
7.Get data from selected row in DataGridGet data from selected row in DataGrid
8.Get DataGrid data providerGet DataGrid data provider
9.Get the returning data from Php and feed it into DataGridGet the returning data from Php and feed it into DataGrid
10.Update Chart data as DataGrid being updatedUpdate Chart data as DataGrid being updated
11.Modifying data in a DataGrid controlThe following example lets you add, remove, or modify data in a DataGrid controlModifying data in a DataGrid controlThe following example lets you add, remove, or modify data in a DataGrid control
12.DataGrid data with Simple AttributesDataGrid data with Simple Attributes
13.DataGrid and DataGrid and <mx:ArrayCollection>
14.DataGrid with object array collectionDataGrid with object array collection
15.Define array with Array collection in ActionScript and use it for DataGridDefine array with Array collection in ActionScript and use it for DataGrid