1 Reply Latest reply on Mar 10, 2010 11:35 AM by Zolotoj

    CheckBox - set selected property

    Zolotoj Level 3

      I am trying to set selected property to provided data.

      ...

      <mx:CheckBox id="check" selected="{XML(data).selected}"

      ...

      and data looks like this:

      <sku40181>

        <action>Audit Existing Inventory</action>

        <selected>false</selected>

      </sku40181>

       

      but the checkbox is selected even <selected>false</selected>. Can someone explain why?

       

      Thanks

        • 1. Re: CheckBox - set selected property
          Zolotoj Level 3

          Ok, here is complete code of my itemRenderer that I am using in dataGird:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
                          xmlns:s="library://ns.adobe.com/flex/spark" 
                          xmlns:mx="library://ns.adobe.com/flex/halo">
               <fx:Script>
                    <![CDATA[
                    import mx.events.FlexEvent;
                    import mx.collections.ArrayCollection;
                    import mx.controls.CheckBox;
                    public var datas:XML;
                    override public function set data(value:Object):void
                    {
                         dataProvider = datas["sku" + value.sku];
                    }               
                    public function saveCheckState(evt:Event):void
                    {
                         var dataProviderItem:Object = dataProvider.getItemAt(dataProvider.getItemIndex(selectedItem));
                         dataProviderItem.selected = CheckBox(evt.currentTarget).selected;
                         dataProvider.setItemAt(dataProviderItem, dataProvider.getItemIndex(selectedItem));     
                    }
                    ]]>
               </fx:Script>
               <mx:itemRenderer>
                    <fx:Component>
                         <mx:HBox width="100%">
                              <mx:Label text="{XML(data).action}"/>
                              <mx:Spacer width="100%"/>
                              <mx:CheckBox id="check" selected="{XML(data).selected}"
                                              change="outerDocument.saveCheckState(event);"/>
                         </mx:HBox>
                    </fx:Component>
               </mx:itemRenderer>
          </mx:ComboBox>
          
           
          What's happening is when I drop this combo down all checkboxes are shown as selected.