1 Reply Latest reply on Feb 1, 2008 12:49 AM by atta707

    DataGrid:populate specific columns with values on Drop

      hi everyone...
      I am new to Flex n right now playing with the most used DataGrid component.
      I have a List control and a DataGrid. I want to drag and drop a item from List to DataGrid.
      Now what i want is Not all but some specific columns should get populated.
      Now according to me the solution is ...

      1) override the dragDropHandler(event:DragEvent) of DataGrid
      2) get the dragSource from event object.
      3) somehow remove the column specific data that we dont want to populate
      4) set the dragSource data again to event object and call super.dragDropHandler(event).

      this is the code..
      override protected function dragDropHandler(event:DragEvent):void

      var dragData:Object = event.dragSource.dataForFormat("items");

      var arrColumns:Array;
      var dgColumn:MyDGColumn; // my custom DataGridColumn with property 'populateOnDrop'
      arrColumns = this.columns;
      var i:int;
      dgColumn = arrColumns ;
      if(dgColumn.populateOnDrop != true)
      { // don't know waht to do here.
      //pls suggest somthing how to change the value in the dragSource for this column to empty string
      // here assign changed dragSource to event object.


      pls suggest if there is another way to do it..
      Thanx in advance...
        • 1. Re: DataGrid:populate specific columns with values on Drop
          atta707 Level 2
          You don't really have to call super.dragDropHandler().

          It really depends what kind of properties you have in dragData object and what kind or properties you have in the underlying data source of the data grid.

          All you need to do is to instantiate a new object of type that are in the underlying data source of the grid, copy properties from the dragged data source and insert the new object into the array collection of the data grid.

          that should work.

          Or am I missing something here?