I don't have the code in front of me right now, but to be more precise, 
dgEmployees is not 
broadcasting a change event upon a D&D action.  I want dgEmployees to broadcast 
an 
event every time there is a change to the DataGrid.  The dgEmployees DataGrid 
has a 
change event method defined, somthing like:

<code>
<mx:DataGrid id="dgEmployees"
 dataProvider="{__employees}"
 change="broadcastEvent(event)"
 ...>
</code>

The broadcastEvent() method constructs a custom event containing the number of 
elements in the DataGrid, and then dispatches it to be used elsewhere.

Now, as I type this, I see that I might have keyed off the wrong event, 
"change".  Not sure if 
that is broadcast upon a change in the dataProvider, BUT  I had been working on 
this code 
previously (converting to Flex 2.0), and I believe that I saw this same issue.

I noticed that when I used the debugger to step throught the doDragDrop() 
method, I was 
seeing  that only the dataProvider was being updated, and not the 
ArrayCollection.  I can't 
verify this until Monday (5/21), but I'm almost 100% sure this is what I saw.


--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> How do you know it didn't update __employees?
> 
>  
> 
> Can you post a mini-example in a couple of screenfuls of text?
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Geoffrey
> Sent: Thursday, May 17, 2007 6:11 PM
> To: [email protected]
> Subject: [flexcoders] Does Drag & Drop Only Update the DataProvider?
> 
>  
> 
> I have a DataGrid that has a dataProvider bound to an ArrayCollection.
> 
> <code>
> <mx:DataGrid id="dgEmployees"
> dataProvider="{__employees}"
> ...>
> </code>
> 
> I also have another DataGrid (dgAllEmployees) that is within a popup,
> which I use as a source for Drag & Drop operations to populate the
> dgEmployee dataGrid.
> 
> What I've noticed is that when I drag & drop employees from the "all
> employees" DataGrid to the "employees" DataGrid, it seems to only
> update the dataProvider of dgEmployees, and not the ArrayCollection
> __employees. Why is this?
> 
> Below is a snip of my drag & drop code where it actually copies the
> data. This is a generic method that is used all over the application.
> <code>
> public static function doDragDrop( event:DragEvent ):void
> {
> // Prevent the default event from happening.
> event.preventDefault();
> 
> // Get drop target
> var dropTarget:DataGrid = DataGrid(event.currentTarget);
> 
> // Get the dragged items from the drag initiator.
> var dropItems:Array = event.dragSource.dataForFormat("items") as Array;
> 
> // Add each item to the drop target.
> for (var i:uint = 0; i < dropItems.length; i++)
> {
> var dest:IList = IList(dropTarget.dataProvider);
> if (!contains(dest, dropItems[i]))
> {
> dest.addItem(dropItems[i]);
> }
> }
> }
> </code>
> 
> I think that I had event.preventDefault(); in there because it was
> putting 2 of each dropped item in the dgEmployee DataGrid. Might this
> be messing something up?
> 
> Also, contains() is a custom method to compare the source items to
> what's in the target's list to prevent duplicates. Is there a better
> way to do this?
> 
> Thanks in advance.
> GT
>


Reply via email to