Okay, after doing some more research I found that the update
"function"(my trace placeholder) is fine where it is, the problem is
that it is firing the insert function for each and every row every
time something is dragged onto the datagrid essentially cloning all
the entries in the database while updating the original items. So I've
narrowed down my problem to figuring out how to get the insert
function to fire only once for new items and skipped when updating
items. I keep thinking that perhaps I might be using the wrong kind of
loop, but other options I can think of amount to the same thing.

I've tried using an else and else if block to enclose the insert
placeholder but it is still doing the same thing. Again, any advice
and help would be greatly appreciated.

--- In [email protected], "bredwards358" <[EMAIL PROTECTED]>
wrote:
>
> In the part of my application that I'm currently working on I'm trying
> to dynamically update a local database every time a change is made to
> the dataProvider(ArrayCollection) when a dragDrop action is done. Here's
> my code so 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
>         }
> }
> -------------------
> The problem is that both the insert and update "functions" are firing
> once the second item is put into the dropTarget's dataProvider which
> would cause many duplicate entries into the database. What I need help
> with is making sure that only an insert or an update is fired when
> needed. I suspect this may have something to do with the for loop
> everything is in but outside input would be appreciated. Thanks in
> advance,
> 
> Brian Ross Edwards
> Tech-Connect LLC
>


Reply via email to