2 Replies Latest reply on Dec 22, 2010 2:00 PM by nordinkhm

    Drag an Drop and Cursors

    nordinkhm

      I have three lists, each one filled with xml data through an arraycollection.

      Below those lists i have a datagrid. People can drag items from those lists to the datagrid.

      The datagrid consists of three columns: Product, Price and Pieces.

      When people drag the same item from those lists i want to count them and show the result in the third column

      of the datagrid.

       

      I tried to use a cursor to count the same items and show the result in the third column of the datagrid, but i don't know

      behind which event i have to put this function:

       

      private

       

       

       

       

       

      function aantalpizza():void{

       

       

      cursor = acaantal.createCursor();

       

      var pizzaobject:Object = {item:mypizzas.selectedItem.item};

       

      if(cursor.findAny(pizzaobject))

      {

      cursor.current.aantal ++

      }

       

      else

      mypizzas.selectedItem.aantal = 1;

       

      }

       

      Does anyone have an idea?

        • 1. Re: Drag an Drop and Cursors
          rtalton Level 4

          You can use the DragEvent of type "dragComplete".

          • 2. Re: Drag an Drop and Cursors
            nordinkhm Level 1

            i tried the following code:

             

            private

             

             

             

             

             

            function aantalpizza(ev:DragEvent):void{

             

            cursor =

            acaantal.createCursor();

             

            var pizzaobject:Object = {item:mypizzas.selectedItem.item};

             

            if(cursor.findAny(pizzaobject))

            {

            cursor.current.aantal ++

            }

             

            else

            mypizzas.selectedItem.aantal = 1;

             

            }

             

            <mx:DataGrid

             

            dragComplete="aantalpizza(event)" dataProvider="{acaantal}" id="dgbestelling" dropEnabled="true">

             

            <mx:columns>

             

            <mx:DataGridColumn dataField="item" headerText="Artikel" resizable="false" width="150"/>

             

            <mx:DataGridColumn dataField="prijs" headerText="Prijs"/>

             

            <mx:DataGridColumn dataField="aantal" headerText="Aantal"/>

             

            </mx:columns>

             

            </mx:DataGrid>

             

            it didn't work, i need the datafield "aantal" to update if the same item is being dragged to the datagrid

            ==> "aantal" means quantity, so if the same item is being dragged , it needs to count the quantity.