[flexcoders] ArrayCollection COLLECTION_CHANGE event doesn't fire right away?

2009-01-23 Thread Keith Hughitt
Hi all,

I'm trying to detect changes in an ArrayCollection which is bound to a
DataGrid with some editable components. For some reason, however, the
event only seems to fire when the focus is change. For example, I
check a check-box, and nothing happens. When I then click somewhere
outside of the checkbox, the event is fired. Furthermore, If I check
the box twice before changing focus, nothing at all happens.

Is is possible that the event is only fired when the DataCollection is
refreshed, and that the refresh is not occurring until the focus changes?

Here is an example of what I'm doing (colors is the id for the
DataGrid associated with the colors ArrayC:

import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import mx.controls.Alert;

[Bindable]
private var colors:ArrayCollection = new ArrayCollection([
{color:Red, display: true},
{color:Blue, display: true},
{color:Green, display: true}
]);

// Watch for changes to DataGrid CheckBox's
private function init():void {
colors.addEventListener(
CollectionEvent.COLLECTION_CHANGE, onChange
);
}

public function onChange(evt:Event):void {
Alert.show(Datagrid altered!);
}

Any ideas? Any advice would be greatly appreciated.


Thanks!
Keith






RE: [flexcoders] ArrayCollection COLLECTION_CHANGE event doesn't fire right away?

2009-01-23 Thread Alex Harui
DG editing is session and row-based by default.  Data isn't written back to the 
data object until you change cells, and notifications are blocked until you 
change rows.

For click-based cells like checkbox, I usually add a change handler that sets 
the field right away.

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Keith Hughitt
Sent: Friday, January 23, 2009 8:24 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] ArrayCollection COLLECTION_CHANGE event doesn't fire 
right away?


Hi all,

I'm trying to detect changes in an ArrayCollection which is bound to a
DataGrid with some editable components. For some reason, however, the
event only seems to fire when the focus is change. For example, I
check a check-box, and nothing happens. When I then click somewhere
outside of the checkbox, the event is fired. Furthermore, If I check
the box twice before changing focus, nothing at all happens.

Is is possible that the event is only fired when the DataCollection is
refreshed, and that the refresh is not occurring until the focus changes?

Here is an example of what I'm doing (colors is the id for the
DataGrid associated with the colors ArrayC:

import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import mx.controls.Alert;

[Bindable]
private var colors:ArrayCollection = new ArrayCollection([
{color:Red, display: true},
{color:Blue, display: true},
{color:Green, display: true}
]);

// Watch for changes to DataGrid CheckBox's
private function init():void {
colors.addEventListener(
CollectionEvent.COLLECTION_CHANGE, onChange
);
}

public function onChange(evt:Event):void {
Alert.show(Datagrid altered!);
}

Any ideas? Any advice would be greatly appreciated.

Thanks!
Keith