Implementing manual drag in a Flex list

I have a Flex application that displays a collection of items in one of several List

depending on how the item is classified. By dragging and dropping items between the lists, the user starts a server-side process that tries to reclassify the items. The server side process then returns some XML that either contains an error message or "OK".

The requirement is that the UI do a "drag and drop" move if the server returns OK and no-op if the server returns an error. Using the default drag handlers (setting dragEnabled=true

and dropEnabled=true

on List

s) always performs drag and drop.

As far as I could tell, the only way to get enough control over things to handle the asynchronous server validation is to manually drag and drop from lists. So I read the Adobe documentation and tried to adapt their example.

The problem I'm running into is that, as far as I can tell, I need to detect the drag by connecting to an event mouseMove

in the list. Then I pass the list as the initiator of the DragManager.doDrag procedure.

Working this way has a number of problems: the default proxy image is the size of the entire list, an attempt to use the scroll bar disables drag detection, etc. Obviously I am doing something wrong.

Has anyone tried to drag and drop List

manually? Is there a trick for defining the drag events correctly? Should I keep track of the actual itemRenderer the user is dragging and dropping this as initiator?

0


a source to share


2 answers


I think your drag initiator should be the handler of the items you are dragging, not the entire List control.



+2


a source


Hmmm ... if I understand what you are trying to do here, you want to drag the blobs, but cancel if the server returns an error?



What I would do is handle the dragEnd event and check the server status. If the server returns an error, just move the data back to the original list and don't add it to the new list, otherwise just follow the default behavior. Feel free to comment on the explanation.

0


a source







All Articles