tags:

views:

40

answers:

2

I have a chechbox in a gridview. i need it disabled for some condition and enabled for other. Problem is how to fetch check box id out side the grid.

Please help ....

A: 

By giving you're check box an ID you should be able to reference it no matter what container objects it's it.

<mx:CheckBox id=myCheckbox ... />

can then be referenced in any script in that file like this:

private function toggleCheckBoxEnabled():void{
    if(some condition){
      myCheckBox.enabled = true;
    }else{
      myCheckBox.enabled = false;
    }
}
invertedSpear
can we give the ID of check box if it is inside the renderer ???it is giving error
Priya
Assigning an ID inside of any looping code tends to break the concept of an ID, as they should be 100% unique, so it isn't good planning to put them in a renderer. I misunderstood that was what was happening since you said gridview I assumed a grid, when you meant a datagrid. I think sophistifunk has a decent answer for you. If his doesn't work you really need to post a code snippet so we can see what you are doing and what your intent is.
invertedSpear
+1  A: 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:pw="http://intelligentpathways.com.au/Flex/v2"&gt;

    <mx:ArrayCollection id="ac">
        <mx:Object name="Alpha" enabled="{true}"/>
        <mx:Object name="Bravo" enabled="{true}"/>
        <mx:Object name="Charlie" enabled="{false}"/>
        <mx:Object name="Delta" enabled="{false}"/>
        <mx:Object name="Echo" enabled="{true}"/>
    </mx:ArrayCollection>

    <mx:Panel horizontalCenter="0" verticalCenter="0" title="Renderer Demo">
        <mx:DataGrid width="500" height="300" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Name" dataField="name"/>
                <mx:DataGridColumn headerText="Enabled?" dataField="enabled"/>
                <mx:DataGridColumn headerText="Checkbox">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:Box paddingLeft="3">
                                <mx:CheckBox label="Foxtrot" enabled="{data.enabled}"/>
                            </mx:Box>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>
    </mx:Panel>

</mx:Application>
Sophistifunk