Skip navigation
Currently Being Moderated

Flex 3 - List - checkbox itemrenderer enabled property

Nov 10, 2010 9:45 AM

I have a list that uses a checkbox itemrenderer.  The dataprovider is a collection of people.  When I load the data from a file, each list item shows the person's name (last, first -- labelFunction), and the checkbox's selected property shows the person's included property.  I.e.,

 

Person
Included?
Smith, Dougx
Williams, Bob
Morris, Annex

 

 

However, each person also has an active property.  I want to disable the checkbox for people who are inactive (meaning, "you can't include inactive people").  I have tried several methods to get this to work, including what's suggested here http://forums.adobe.com/thread/416786 to do the same thing in a datagrid.  However, none of them work and all the checkboxes are enabled regardless of the person's active status.  Here is my basic code:

 

<mx:List id="peopleIncludedList"
     dataProvider="{someProvider}"
     labelFunction="peopleLabelFunction">
     <mx:itemRenderer>
          <mx:Component>
               <mx:CheckBox change="onChange(event)"
                    selected="{outerDocument.isIncluded(data)}">
                    <mx:Script>
                         <![CDATA[
                                    
                              private function onChange(e:Event):void
                              {
                                   ...
                              }
                         ]]>
                    </mx:Script>
               </mx:CheckBox>
          </mx:Component>
     </mx:itemRenderer>
</mx:List>

 

Any help on this would be greatly appreciated.  Thank you.

 

  -- Ian

 
Replies
  • Currently Being Moderated
    Nov 10, 2010 12:31 PM   in reply to istrasci

    Try wrapping the Checkbox in something else so the checkbox itself can be

    disabled w/o disabling the entire renderer.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 1:27 PM   in reply to Flex harUI

    Couldnt you do something like this? Just bind the "enabled" property?

     

                   <mx:CheckBox change="onChange(event)"
                        selected="{outerDocument.isIncluded(data)}"
                        enabled
    ="{data.IsThisPersonActiveField}"
                        >
                        <mx:Script>
                             <![CDATA[
                                       
                                  private function onChange(e:Event):void
                                  {
                                       ...
                                  }
                             ]]>
                        </mx:Script>
                   </mx:CheckBox>
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 1:46 PM   in reply to istrasci

    It should work....

     

    What is the value in that field? Maybe it needs to be translated to TRUE or FALSE, instead of whatever value is really in there?? What is the datatype for {data.IsThisGuyInactiveField} ?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 1:55 PM   in reply to istrasci

    Usually when I see behaviour like that, yourlistcomponent.ValidateNow() works and fixes it.

     

    How is your dataprovider set? Is it done in ActionScript? If so, you could try to do the "ValidateNow" to force it to draw immediately. I dunno, I am going out on a limb here, lol.

     

    Also, can you debug into the dataprovider, to verify that "true" or "false" really exists for that field? My guess is that the underlying value is not there or different than what you expect. Try to debug the dataprovider to see if its truly "true or false"?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 2:54 PM   in reply to Devtron

    I don't have time to check, but I recall that the renderers are set to

    enabled=true during recycling.  That's why I'd try burying it one level

    deeper.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points