collectionChange doesn't appear to be a valid DataGrid event, but I
tried dataChanged, added, add, valueCommit, and updateComplete.  None
of these did what I wanted, and actually, I have verified that the
__employees ArrayCollection does not update after a D&D event.

Looking through everything in debug mode, I'm seeing that the
dataProvider of the DataGrid is updated after D&D, but not the bound
variable __employees.
I wonder if it's how I declared the variable?  I did it like so:
<code>
[Bindable]
private var __employees:ArrayCollection;

public function get employees():ArrayCollection {
        return __employees;
}

public function set employees( employees:ArrayCollection ):void {
        if (employees != null) {
                __employees = employees;
        }
}
</code>

Maybe I should just make it public?  Nope, that didn't work.

I'm also wondering if the "event.preventDefault();" is messing
something up.  Nope, that just prevents the the base class ListBase
from doing it's D&D handling.  Since this doesn't check for
duplicates, I don't want to use it.

I'm not sure what to do....



--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Mx:DataGrid's change event is for when selection changes, not when the
> collection changes.  Could that be the issue?  collectionChange may be
> what you want.
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Geoffrey
> Sent: Friday, May 18, 2007 10:12 AM
> To: [email protected]
> Subject: [flexcoders] Re: Does Drag & Drop Only Update the DataProvider?
> 
>  
> 
> 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] <mailto:flexcoders%40yahoogroups.com>
> , "Alex Harui" <aharui@> 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:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of Geoffrey
> > Sent: Thursday, May 17, 2007 6:11 PM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> > 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