1 Reply Latest reply on Mar 8, 2010 7:12 AM by rickcr

    Using checkboxes as datasource of TileList - how do I then receive selected checkboxes?

    rickcr

      I've been googling and searching for this and it should be simple I'd imagine... (I'm new to Flex so that probably doesn't help:)...

       

       

      I have an array that I create using CheckBox components. I then use this array as the dataprovider for a TileList and then also create a CheckBox itemrenderer.

       

      The issue I'm having is that, I thought if I went over the underlying checkbox array at a later point (say a button click) - that I'd be able to see some selected items yet none of them show up selected as I iterate over them (even though I've checked some of the checkboxes.)

       

      I have an event on the checkbox rendererer itself and when it fires I do see the selected property set - It's just going over the whole array that I'm not seeing them set. It's as if the underlying dataset is not being modified. What do I need to do so that I can capture the selected checkbox items?  (Is the issue something to do with the renderer being reused?)  I'm thinking getting a handle to checkbox items from from a TileList would be somewhat common so any help/examples appreciated.

       

      Below is the pertinent code:

       

      [CODE]
      dataArray is an array of type [B]CheckBox[/B]

       

      <mx:TileList id="reportMetricsBox"
              borderStyle="solid" height="100%" width="100%" maxColumns="3"
              columnWidth="110" paddingLeft="0" textAlign="left" borderThickness="0"
              dataProvider="{dataArray}">
         <mx:itemRenderer>
             <mx:Component>
                 <mx:CheckBox click="handleClick(event)">
                     <mx:Script>
                         <![CDATA[
                             import com.foo.event.CheckBoxEvent;

       

                             private function handleClick(event:Event):void {
                                 dispatchEvent(new CheckBoxEvent(CheckBoxEvent.CLICKED, CheckBox(this)));
                             }
                         ]]>
                     </mx:Script>
                 </mx:CheckBox>
             </mx:Component>
         </mx:itemRenderer>
      </mx:TileList>
      [/CODE]