draggedItems should be the row from the source

 

dataProvider is the dataProvider for the destination

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of bredwards358
Sent: Monday, June 02, 2008 5:31 AM
To: [email protected]
Subject: [flexcoders] Re: Questions regarding updating dataProviders
after a drag & drop

 

Okay, I kind of get what you're saying, it makes sense however I have
some questions to clear things up further, nothing big, just simple
things. Check below for the blue text, in the meantime I'll experiment,
Thanks a bunch I appreciate it.

Brian Ross Edwards,
Tech-Connect LLC.

--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Normally, you listen for dragDrop or dragComplete events and if you
> don't want default behavior, you call preventDefault on the event and
do
> whatever you want.
> 
> 
> 
> So, if I were handling dragging products to a shopping list, I would
> write something like this:
> 
> 
> 
> public function dragDropHandler(event:DragEvent):void
> 
> {
> 
> var draggedItems:Array =
> event.dragSource.dataForFormat("items");//Is items simply a generic
name or the name of what you're dragging from?
> 
> var draggedItem:Product = draggeItems[0];//Am I correct in assuming
that this is the row of the dataGrid being dragged from?
> 
> 
> 
> // search array collection for existing object
> 
> var ac:ArrayCollection = dataProvider;//This is the dataProvider of
the dataGrid being dropped on, right?
> 
> var n:int = ac.length;
> 
> for (var i:int = 0; I < n; i++)
> 
> {
> 
> If (ac[i].productKey == draggedItem.productKey)
> 
> {
> 
> ac[i].quantity ++;
> 
> ! event.preventDefault();
> 
>! ; return;
> 
> } 
> 
> }
> 
> // if we don't exit via preventDefault()/return, then
> default behavior will add it to the dataProvider
> 
> }

 

Reply via email to