1 Reply Latest reply on Feb 6, 2008 12:01 PM by Flex harUI

    Drag drop between datagrids/lists component

    Tikis_Mikis Level 1
      Hello so I have a datagrid from which I drag rows to drop in list component. That functions just fine. However I am having a certain issue I don't know how to fix.

      Lets say I have a datagrid with three rows and each row has two columns, say "name" and "description", so a data set looks like this:

      //sample:
      alex, alex is nice
      mary, mary is not nice

      I am able to drag and drop any of those rows into my list component in which I only display the name so if I drag "alex, alex is nice" to my list component I get this in my list component:

      alex

      The problem I am having is when I drag and drop the same rows from datagrid to the list over and over again. as in i get a list that looks lik this:

      alex
      mary
      mary
      alex
      alex
      alex
      mary

      It seems that the list doesnt realize that each row being dropped should be a completely new item in its data provider So in the data set above if I i mouse over the first "alex" the one that gets highlighted is the very last "alex" toward the bottom.

      I wasnt sure if I should post any code but here are my list and datagrid components along with the specific AS3 code:

      Code:

      <mx:List id="listMySet"
      height="247" width="216" x="10" y="35"
      dataProvider="{myList}"
      dropEnabled="true"
      dragDrop="testDragDrop(event)"/>

      <mx:DataGrid x="234" y="35" width="339" height="247"
      id="myGrid"
      dataProvider="{originalList}"
      horizontalScrollPolicy="on"
      draggableColumns="false"
      editable="false"
      horizontalScrollPosition="0"
      resizableColumns="false"
      sortableColumns="false"
      dragEnabled="true">
      <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="first_name" width="200"/>
      <mx:DataGridColumn headerText="Description" dataField="name_description"/>
      </mx:columns>
      </mx:DataGrid>

      here is the AS3 code:
      ActionScript Code:

      [Bindable] public var originalList:ArrayCollection;
      [Bindable] public var myList:ArrayCollection;

      private function testDragDrop(event:DragEvent):void {
      var targetRow:Object = new Object();
      targetRow = event.dragSource.dataForFormat("items");
      listMySet.dataProvider.addItem(targetRow[0].first_name);
      event.preventDefault();
      }

      any help? please