0 Replies Latest reply on Apr 7, 2010 4:59 PM by dimdim20

    changing dropped data during drag and drop from one datagrid to another

    dimdim20

      I have two datagrids in my application with their own datasources and I want to drag a row from the first datagrid and be able to drop it in the second datagrid (I am copying the row and not moving). Now this is pretty easy using the inbuild flex datagrid drag drop feature.

      The tricky part is I have to change the values of some of the attributes when I drop it in the second grid without affecting the values the dragged row in the first datagrid.

      This is the function that I am calling on dragDrop

       

            private function doDragDrop(event:DragEvent):void{

                       

                        var dropIndex:int = targetDataGrid.calculateDropIndex(event);

                 

                       

                        var items:XML = event.dragSource.dataForFormat("items")[0] as XML;

                       

                  for each (var obj:Object in items)

                  {

                        items.@id = "new id";

                       

                       

                  }

                 

                 

      The row that I am dragging looks something like this (this is just an example and the actual data will be different)

      <data id=”2” index1=”45” data1=”356”>

       

      What I am trying to do it change the values of id of this row when I drop it in the second grid (the second grid will have a different id)

      In the example above I am trying to do that by accessing item.@id and setting the new id there.

      But what happens is the id of this dragged row in the first datagrid also changes. Since I am dragging and not doing move that is the same row existing in the first datagrid and a copy of it is put in the second datagrid on drag and drag

      How I just change the value of id of this dropped row in the second datagrid without affecting the value of attributes of the dragged row in the first datagrid.

       

      Sorry guys if this is confusing. I have spend so much time and energy on this but no solutions yet.