R – Flex Drag and Drop

apache-flexdrag and drop

I am creating an application that will allow users to model configuration information by allowing them to Drag and Drop objects from a Flex Tree into a DataGrid.

I know that both the Tree and DataGrid both support Drag and Drop quite well.

My problem is that I want users to drop items from the Tree into a particular Datagrid cell. I think standard drop events into the Datagrid try to fill the whole datagrid row by default. This is not what I want, I want to drop components into a cell only.

I was thinking that each time an object is dropped onto the datagrid you would have to:
– Get the cell location (x,y) the object was dropped into
– Get all the existing cell objects and rebuild that datagrid row from scratch(dynamically) adding the new dropped object to the row in its correct position. Thus giving the illusion that you can drop into a cell – its a bit of a fudge but I think it could work 🙂

Any feedback would be great.
Thanks in advance
Mike

Best Answer

Turn drag and drop off for the datagrid.

Write a custom renderer which listens to itself for the DragEnter / DragDrop events. In the handler for the drop event, add the item(s) to the data (at the variable referenced by that column).

If your renderer is bound to the item, it will now update.

((Note that isn't best practice, you'd want to dispatch an event containing the renderer's data item, the variable it was representing and the item(s) dropped, and then manipulate the dataprovider outside of the renderer))

Related Topic