views:

1130

answers:

2

Hi

I have a Flex List which is databound to a Array. My problem is that when I reorder the List using the built in dragMoveEnabled, the values are reset to the original values.

I assume I need to somehow do a two-way databinding but I am not sure how.

<mx:List width="100%"  top="20"   id="uiItemList" dragMoveEnabled="true" bottom="0" 
             dragEnabled="true" dropEnabled="true" 
 dataProvider="{listArray}"   >
 <mx:itemRenderer>
  <mx:Component>
   <mx:HBox width="100%" height="25" >
    <mx:CheckBox id="uiCheck" textAlign="center" selected="{data.IsDone}" mouseDown="event.stopImmediatePropagation();"  />
   </mx:HBox> 
  </mx:Component>
 </mx:itemRenderer>
</mx:List>

[Bindable]
public var listArray : ArrayCollection = new ArrayCollection ();
A: 

Maybe you can try:

selectedField = "IsDone"
CookieOfFortune
A: 

itemRenderer, by itself, only renders the data. Here's what I found works:

<mx:ArrayCollection id="listArray">
  <mx:Array>
    <mx:Object label="Item One" checked="false" />
    <mx:Object label="Item Two" checked="true" />
  </mx:Array>
</mx:ArrayCollection>
<mx:List dataProvider="{listArray}" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" editable="true" rendererIsEditor="true" editorDataField="data">
  <mx:itemRenderer>
    <mx:Component>
      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
        <mx:Script>
          <![CDATA[
 private var _data:Object;

 [Bindable]
 override public function set data(value:Object):void {
  _data = value;
 }

 override public function get data():Object {
  return _data;
 }
          ]]>
        </mx:Script>
        <mx:CheckBox selected="{data.checked}" />
        <mx:Label text="{data.label}" />               
      </mx:HBox>
    </mx:Component>
  </mx:itemRenderer>
</mx:List>

If you update a checkbox, you need to select another item before you can relocate the edited item in the list. Hope that helps!

Phil Hayward