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

2009-01-23 Thread Keith Hughitt
Hi Alex,

Thanks for the suggestion. I was already trying to set the value using
the click-handler, but even using change, I still am not having any luck:

change=cbSelected = displayCheckBox.selected;

(The data-binding is somewhat indirect: the checkbox sits inside a
HBox, which I've given a cbSelected property that is then set as the
columns editorDataField field, similar to the last example from the
Returning data from an item editor section:
http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_1.html
in the Flex 3 Help pages.)

Am I setting the change handler properly?

Thanks,
Keith




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

2009-01-23 Thread Alex Harui
Click should be just as good, but usually the code looks like:

Click=data.someProperty = displayCheckBox.selected because data is the 
arraycollection item you are editing.  If the data objects are not [bindable], 
then you further have to call arrayCollection.itemUpdated() to force a 
collection change event.

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


Hi Alex,

Thanks for the suggestion. I was already trying to set the value using
the click-handler, but even using change, I still am not having any luck:

change=cbSelected = displayCheckBox.selected;

(The data-binding is somewhat indirect: the checkbox sits inside a
HBox, which I've given a cbSelected property that is then set as the
columns editorDataField field, similar to the last example from the
Returning data from an item editor section:
http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_1.html
in the Flex 3 Help pages.)

Am I setting the change handler properly?

Thanks,
Keith



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

2009-01-23 Thread Keith Hughitt
I was able to get it working  in one case using itemUpdated. I had to
change the ArrayCollection to public, and then set the handler:

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

  private function init():void {
  colors.addEventListener(CollectionEvent.COLLECTION_CHANGE,
onChange);
  }
.
.
.
mx:DataGridColumn dataField=display rendererIsEditor=true
editorDataField=selected
 mx:itemRenderer
 mx:Component
 mx:CheckBox label={data.color} selected=true
click=data.display = selected; outerDocument.colors.itemUpdated(data);
/
 /mx:Component
 /mx:itemRenderer
/mx:DataGridColumn


I still cannot get it working in the more complex case where I have a
more complex component item renderer:


 mx:DataGrid id=colorDG dataProvider={colors} editable=true
 mx:columns
 mx:DataGridColumn headerText=Color dataField=display
rendererIsEditor=true editorDataField=cbSelected
 mx:itemRenderer
 mx:Component
 mx:HBox horizontalAlign=left paddingLeft=5
 mx:Script
 ![CDATA[
 [Bindable]
 public var cbSelected:Boolean;
 ]]
 /mx:Script

 mx:CheckBox id=displayCheckBox
selected=true change=cbSelected = displayCheckBox.selected;
outerDocument.colors.itemUpdated(data); /
 mx:Label text={data.color} /
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:DataGridColumn
 /mx:columns
 /mx:DataGrid


When I click the checkbox in the above example, the COLLECTION_CHANGE
event is fired three times: the 1st and 3rd time with the prior (wrong)
value and the middle time with the updated (correct) value. When I use
data.selected = displayCheckBox.selected the event is fired anywhere
between once and three times and the wrong values end up being stored in
ArrayCollection.

The version I got working is good enough for the time being, but If
anyone can tell what I'm doing wrong in the later example, I would love
to find out so I can understand the SDK better.

Thanks for your help Alex!
Keith




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

2009-01-23 Thread Alex Harui
Well, I don't know for sure if this is the issue, but an HBox is not an 
IFocusManagerComponent and thus probably doesn't get focus handled correctly.  
Editable renderers should implement IFocusManagerComponent.

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


I was able to get it working  in one case using itemUpdated. I had to change 
the ArrayCollection to public, and then set the handler:
[Bindable]
public var colors:ArrayCollection = new ArrayCollection([
{color:Red, display: true},
{color:Blue, display: true},
{color:Green, display: true}
]);
! private function init():void {
 colors.addEventListener(CollectionEvent.COLLECTION_CHANGE, onChange);
 }
.
.
.
mx:DataGridColumn dataField=display rendererIsEditor=true 
editorDataField=selected
mx:itemRenderer
mx:Component
mx:CheckBox label={data.color} selected=true 
click=data.display = selected; outerDocument.colors.itemUpdated(data); /
   ! ; /mx:Component
/mx:itemRend! erer
/mx:DataGridColumn


I still cannot get it working in the more complex case where I have a more 
complex component item renderer:

mx:DataGrid id=colorDG dataProvider={colors} editable=true
mx:columns
mx:DataGridColumn headerText=Color dataField=display 
rendererIsEditor=true editorDataField=cbSelected
mx:itemRenderermx:Component
mx:HBox horizontalAlign=left paddingLeft=5
mx:Script
![CDATA[
[Bindable]
public var cbSelected:Boolean;
]]
  n! bsp; /mx:Script

mx:CheckBox id=displayCheckBox selected=true 
change=cbSelected = displayCheckBox.selected; 
outerDocument.colors.itemUpdated(data); /
 nb! sp;  mx:Label text={data.color} /
/mx:HBox
/mx:Component
/mx:itemRenderer
/mx:DataGridColumn
/mx:columns
! /mx:DataGrid


When I click the checkbox in the above example, the COLLECTION_CHANGE event is 
fired three times: the 1st and 3rd time with the prior (wrong) value and the 
middle time with the updated (correct) value. When I use data.selected = 
displayCheckBox.selected the event is fired anywhere between once and three 
times and the wrong values end up being stored in ArrayCollection.

The version I got working is good enough for the time being, but If anyone can 
tell what I'm doing wrong in the later example, I would love to find out so I 
can understand the SDK better.

Thanks for your help Alex!
Keith