2 Replies Latest reply on Sep 28, 2009 3:27 AM by Flexplorer

    Drag'n'drop within mx:Repeater

    Flexplorer

      Hi,

      I wonder why mx:Repeater has not the same facilities for drag'n'drop than mx:List or mx:Datagrid.

      I have a mx:Repeater for an objects collection. For each object, I use a custom component as renderer/editor.

      I would like to change created components position to update a object index in objects collection.

      I have made my custom component draggable and mx:Repeater container (here custom mx:VBox) droppable.

      But I don't know how to get old position and new position (after drop) of a dragged component compared with components collection created by the repeater.

      In a mx:Datagrid, there is a little cursor (a line black line) which appears between list elements when we drag an object over them and when we drop it, current object takes the place of this cursor and list display is automatically updated.

      I would like to implement the same mechanism but in a repeater.

      Is it possible and if yes, any ideas to implement it ?

      Regards

        • 1. Re: Drag'n'drop within mx:Repeater
          Flexplorer Level 1

          Has anyone ever encountered this problem ?

          • 2. Re: Drag'n'drop within mx:Repeater
            Flexplorer Level 1

            ok, for those who are interested in, I found a solution. In fact, it's quite simple. (NB : I use PureMVC framework)

            Each of my custom component (V) created by repeater is managed by a relative mediator (C). And the repeater is contained by a custom panel (V) which gets a relative mediator too.

            I register each custom component mediator on MouseEvent.MOUSE_MOVE (for detecting component drag) and on DragEvent.DRAG_ENTER and DragEvent.DRAG_DROP (for detecting component drop). In fact, custom component is, in the same time, a draggable component and a droppable area.

            When I detect a DragEvent.DRAG_DROP, I send to custom panel mediator a notification which contains dragged custom component and custom component which has received drop action.

            In custom panel mediator, I insert to objects collection (M) (data provider of the repeater) dragged custom component at index of custom component which has received drop action and remove object at index of dragged component. Repeater is automatically refresh thanks to binding and now I have a functionnal drag'n'drop on my repeater.