Why not just set a flag instead of calling preventDefault, then check
the flag afterwards.

 

BTW, you shouldn't be dispatching COLLECTION_CHANGE yourself.  Best to
use itemUpdated when changing quantity.  A COLLECTION_CHANGE will fire
when the default code inserts the dropped items.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of bredwards358
Sent: Saturday, June 14, 2008 9:01 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Help me understand custom drag/drop events

 

I do want the dragged items inserted into the DP, I just want to add a
function call to the end of that which inserts the new row into a
local database table. My problem is that the for-loop which checks for
duplicate entries and merely prevents the default event and updates a
value in the DP makes it difficult to do what I want without doing it
for every row in the DP. Here's what I have thus far:

private function dragToOrders(event:DragEvent):void
{
var draggedItems:Object = new Object();
draggedItems = event.dragSource.dataForFormat("items");
var n:int = orderDetailArray.length;
for (var i:int = 0; i < n; i++)//Looping through to check for
duplicate entries
{
if (orderDetailArray[i].UniqueID == draggedItems[0].UniqueID)
{
orderDetailArray[i].Qty ++;
event.preventDefault();
adgOrders.dataProvider.dispatchEvent(new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
trace("Update fired");//Placeholder foractual update
function
return;
}
adgOrders.dataProvider.dispatchEvent(new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
trace("Insert fired"); //Placeholder for actual insert
function
}
}

Works well and perfect for just putting new items into the data
provider and updating current ones, but while I can update items in
the both the DP and the database just fine, I just can't figure out
where to put the function call to my insert function to put a new row
in the DB. So basically I figured early Friday was to see if it was
possible to modify the default event ever so slightly, to call the
insertToDataBaseFunction(); right after the normal behavior of
inserting it into the dataProvider.

Looks simple, problem is, I'm just not sure where to start.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> IIRC, the DragDrop event is the right place and you were already doing
> that. If you don't preventDefault that event, it will insert the
> dragged items into the DP. I haven't been paying close attention so
I'm
> not clear what problem you ran into that makes you think this isn't
the
> way to go.
> 
> 

 

Reply via email to